\documentclass[12pt]{article}
\usepackage{times}
\usepackage{graphicx}
\usepackage{sidecap}
\usepackage{wrapfig}
\usepackage{fancyhdr}
\pagestyle{fancy}
\renewcommand{\baselinestretch}{1.2}
\newenvironment{mylisting}
{\begin{list}{}{\setlength{\leftmargin}{1em}}\item\scriptsize\bfseries}
{\end{list}}
\newenvironment{mylisting2}
{\begin{list}{}{\setlength{\leftmargin}{1em}}\item\scriptsize\bfseries}
{\end{list}}

%%% This file is Open Content

\begin{document}
	\textbf{{\Huge Evermeet}}
{\center{Dec 29, 2011, 
	Johan Ceuppens, Theo D'Hondt - Vrije Universiteit Brussel}}
\\
{\large{\textbf{\center Abstract}}}
\\
\\
\section{\large Introduction}



\begin{mylisting}
\begin{verbatim}

	

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from time import *
from math import *
from rng import *

class Abeille2(Gameobject):
    "Flying Bee 2"
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 48
        self.h = 48
        self.PI = 3.14182829
        self.hitpoints = 1
        
	self.stimlib = Stateimagelibrary()
        image = pygame.image.load('./pics/abeille1-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/abeille2-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/abeille3-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlib.addpicture(image)
        #self.bodyimage = pygame.image.load('./pics/snakebody1-48x48.bmp').convert()
        #self.bodyimage.set_colorkey((0,0,0)) 
	
	self.talkcounter = 0
	self.direction = "down"

        self.angle = sqrt(2)/2

    def draw(self, screen, room):
        if self.hitpoints <= 0:
            for i in range(0,len(room.gameobjects)):
                if room.gameobjects[i] == self:
                    room.gameobjects[i] = None
                    return
##        sleep(.1) # FIX goblin sleep
        self.angle += self.PI/8
        self.x -= 2
##        self.y = sin(self.angle)*20
##        screen.blit(self.bodyimage, (self.x+room.relativex,self.y+room.relativey))
##        self.angle += self.PI/8
##        self.y = sin(self.angle)*20
##        screen.blit(self.bodyimage, (self.x-10+room.relativex,self.y+room.relativey))
##        self.angle += self.PI/8
##        self.y = sin(self.angle)*20
##        screen.blit(self.bodyimage, (self.x-20+room.relativex,self.y+room.relativey))
##        self.angle += self.PI/8
##        self.y = sin(self.angle)*20
##        screen.blit(self.bodyimage, (self.x-30+room.relativex,self.y+room.relativey))

        self.angle += self.PI/8
        self.x -= 10
        self.yy = sin(self.angle)*20
        self.stimlib.draw(screen, self.x-40+room.relativex,self.yy+self.y+room.relativey)
##        self.angle -= self.PI/8
##        self.angle -= self.PI/8
##        self.angle -= self.PI/8
	     
    def update(self,room,player):
        

        return
        

    def collide(self, room, player):
        # FIX BUG
        #print 'gameobject x=%d y=%d player x=%d y=%d' % (self.x,self.y,player.x-room.relativex,player.y-room.relativey)
	if (player.x-room.relativex > self.x-self.w  and 
	player.x-room.relativex < self.x+self.w+self.w and 
	player.y-room.relativey > self.y-self.h and 
	player.y-room.relativey < self.y + self.h +self.h):
	    print "collision with Abeille2!"
	    return 1 
	else:
	    return 0 ## for game self.talker


    def collidewithsword(self, room, player):
        #print 'Abeille2 x=%d y=%d player x=%d y=%d' % (self.x,self.y,player.x-room.relativex,player.y-room.relativey)
	if (player.x-room.relativex > self.x -self.w  and 
	player.x-room.relativex < self.x+self.w and 
	player.y-room.relativey > self.y -self.h and 
	player.y-room.relativey < self.y + self.h):
	    print "collision with Sword Digdogger!"
	    return 1 
	else:
	    return 0

    def fight(self,room,player):
        self.fightcounter = 1
        o = player.collidewithenemyweapon(room,self)
        if o:
            player.hitwithenemyweapon(RNG().rollgoblinknife())

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from time import *
from math import *
from rng import *

class Abeille(Gameobject):
    "Flying Bee"
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 48
        self.h = 48
        self.PI = 3.14182829
        self.hitpoints = 1
        
		
        self.headimage = pygame.image.load('./pics/abeille1-48x48.bmp').convert()
        self.headimage.set_colorkey((0,0,255)) 
		
        #self.bodyimage = pygame.image.load('./pics/snakebody1-48x48.bmp').convert()
        #self.bodyimage.set_colorkey((0,0,0)) 
	
	self.talkcounter = 0
	self.direction = "down"

        self.angle = sqrt(2)/2

    def draw(self, screen, room):
        if self.hitpoints <= 0:
            for i in range(0,len(room.gameobjects)):
                if room.gameobjects[i] == self:
                    room.gameobjects[i] = None
                    return
##        sleep(.1) # FIX goblin sleep
        self.angle += self.PI/8
        self.x -= 2
##        self.y = sin(self.angle)*20
##        screen.blit(self.bodyimage, (self.x+room.relativex,self.y+room.relativey))
##        self.angle += self.PI/8
##        self.y = sin(self.angle)*20
##        screen.blit(self.bodyimage, (self.x-10+room.relativex,self.y+room.relativey))
##        self.angle += self.PI/8
##        self.y = sin(self.angle)*20
##        screen.blit(self.bodyimage, (self.x-20+room.relativex,self.y+room.relativey))
##        self.angle += self.PI/8
##        self.y = sin(self.angle)*20
##        screen.blit(self.bodyimage, (self.x-30+room.relativex,self.y+room.relativey))

        self.angle += self.PI/8
        self.x -= 10
        self.yy = sin(self.angle)*20
        screen.blit(self.headimage, (self.x-40+room.relativex,self.yy+self.y+room.relativey))
##        self.angle -= self.PI/8
##        self.angle -= self.PI/8
##        self.angle -= self.PI/8
	     
    def update(self,room,player):
        1
        

    def collide(self, room, player):
        # FIX BUG
        #print 'gameobject x=%d y=%d player x=%d y=%d' % (self.x,self.y,player.x-room.relativex,player.y-room.relativey)
	if (player.x-room.relativex > self.x-self.w  and 
	player.x-room.relativex < self.x+self.w+self.w and 
	player.y-room.relativey > self.y-self.h and 
	player.y-room.relativey < self.y + self.h +self.h):
	    print "collision with Abeille!"
	    return 1 
	else:
	    return 0 ## for game self.talker


    def collidewithsword(self, room, player):
        #print 'Abeille x=%d y=%d player x=%d y=%d' % (self.x,self.y,player.x-room.relativex,player.y-room.relativey)
	if (player.x-room.relativex > self.x -self.w  and 
	player.x-room.relativex < self.x+self.w and 
	player.y-room.relativey > self.y -self.h and 
	player.y-room.relativey < self.y + self.h):
	    print "collision with Sword Digdogger!"
	    return 1 
	else:
	    return 0

    def fight(self,room,player):
        self.fightcounter = 1
        o = player.collidewithenemyweapon(room,self)
        if o:
            player.hitwithenemyweapon(RNG().rollgoblinknife())

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from time import *
from venomspit import *

class ArchGohma(Gameobject):
    "Arch Gohma enemy"
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 86
        self.h = 63 
	self.stimlibleft = Stateimagelibrary()	
	self.stimlibright = Stateimagelibrary()	
        image = pygame.image.load('./pics/archgohma1-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/archgohma1-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/archgohma1-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/archgohma1-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/archgohma1-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/archgohma1-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/archgohma2-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/archgohma2-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/archgohma2-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/archgohma2-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/archgohma2-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/archgohma2-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/archgohma3-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/archgohma3-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/archgohma3-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/archgohma3-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/archgohma3-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/archgohma3-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
        image = pygame.image.load('./pics/archgohma2-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/archgohma2-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/archgohma2-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/archgohma2-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/archgohma2-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/archgohma2-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
        image = pygame.image.load('./pics/archgohma1-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/archgohma1-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/archgohma1-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/archgohma1-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/archgohma1-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/archgohma1-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/archgohma2-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/archgohma2-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/archgohma2-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/archgohma2-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/archgohma2-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/archgohma2-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/archgohma2-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/archgohma2-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/archgohma3-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/archgohma3-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/archgohma3-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/archgohma3-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/archgohma3-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/archgohma3-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/archgohma3-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/archgohma3-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
        image = pygame.image.load('./pics/archgohma2-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/archgohma2-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/archgohma2-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/archgohma2-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/archgohma2-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/archgohma2-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/archgohma2-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/archgohma2-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	self.direction = "left"

    def draw(self, screen, room):
	if (self.direction == "left"):
            self.stimlibleft.draw(screen, self.x+room.relativex,self.y+room.relativey)
	elif (self.direction == "right"):
            self.stimlibright.draw(screen, self.x+room.relativex,self.y+room.relativey)
	    
	     
    def update(self,room):
        sleep(.01) # FIX darkknight sleep
	if (random.randint(0,100) == 0 and self.direction == "left"):
	   self.direction = "right"
	elif (random.randint(0,100) == 0 and self.direction == "right"):
	   self.direction = "left"

	if (not self.collideobjectX(room)): 
	    if (self.direction == "left"):
	        self.x +=2
	        self.direction = "right" 
	    elif (self.direction == "right"):
	        self.x -=2
	        self.direction = "left"


	if (self.direction == "left"):
	        self.x -=1 
	elif (self.direction == "right"):
	        self.x +=1

        if random.randint(0,300) == 0:
            room.gameobjects.append(Venomspit(self.x+self.w/2,self.y+self.h))

    def collide(self, room, player):
	if (player.x > self.x+room.relativex  and 
	player.x < self.x+room.relativex+self.w and 
	player.y > self.y+room.relativey and 
	player.y < self.y+room.relativey + self.h):
	    print "collision with ArchGohma!"
	    if player.hit():
		return 1 
	    else:
	    	return 2 
	else:
	    return 0

		 

# Copyright (C) Johan Ceuppens 2010 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *

class Arrow(Gameobject):
    "Box"
    def __init__(self, xx,yy,ox,oy,player):
        Gameobject.__init__(self,xx,yy)
        self.ox = ox
        self.oy = oy
        self.hitpoints = 1000000000 #FIX else wall/floor disappears
        #FIX is in base class self.image = pygame.image.load('./pics/.bmp').convert()
        #self.image.set_colorkey((0,0,0)) 
        self.image = pygame.image.load('./pics/arrow1-16x16.bmp').convert()
        self.image.set_colorkey((0,0,255)) 
        self.image2 = pygame.image.load('./pics/arrowleft1-16x16.bmp').convert()
        self.image2.set_colorkey((0,0,255)) 

	self.player = player


    def draw(self, screen, room):
        if self.player.x+room.relativex < self.ox:
		screen.blit(self.image,(self.x-room.relativex,self.y-room.relativey))
        else:
		screen.blit(self.image2,(self.x-room.relativex,self.y-room.relativey))

    def update(self,room,player):
	if player.x+room.relativex < self.ox:
		self.x += 15
	elif player.x+room.relativex > self.ox:
		self.x -= 15
		
	if abs(self.x-self.ox) < 20:
		room.removeobject(self)

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from time import *

class Assassin(Gameobject):
    "Assassin NPC"
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 48
        self.h = 48 
	self.stimlibdown = Stateimagelibrary()	
	self.stimlibup = Stateimagelibrary()	
        image = pygame.image.load('./pics/assassin1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)	
        image = pygame.image.load('./pics/assassin1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/assassin1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/assassin1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)

	image = pygame.image.load('./pics/assassin2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)	
        image = pygame.image.load('./pics/assassin2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/assassin2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/assassin2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)

        image = pygame.image.load('./pics/assassin3-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)	
        image = pygame.image.load('./pics/assassin3-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/assassin3-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/assassin3-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)

        image = pygame.image.load('./pics/assassin2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)	
        image = pygame.image.load('./pics/assassin2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/assassin2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/assassin2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)

        image = pygame.image.load('./pics/assassinup1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/assassinup1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/assassinup1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/assassinup1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)

	image = pygame.image.load('./pics/assassinup2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/assassinup2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/assassinup2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/assassinup2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)

	image = pygame.image.load('./pics/assassinup3-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/assassinup3-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/assassinup3-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/assassinup3-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
        	
        image = pygame.image.load('./pics/assassinup2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/assassinup2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/assassinup2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/assassinup2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)

	self.talkcounter = 0
	self.direction = "down"

    def draw(self, screen, room):
	if (self.direction == "down"):
            self.stimlibdown.draw(screen, self.x+room.relativex,self.y+room.relativey)
	elif (self.direction == "up"):
            self.stimlibup.draw(screen, self.x+room.relativex,self.y+room.relativey)
	    
	     
    def update(self,room):
        sleep(.04) # FIX assassin sleep
	
	if (not self.collideobjectY(room)): 
	    if (self.direction == "down"):
	        self.y -=2
	        self.direction = "up" 
	    elif (self.direction == "up"):
	        self.y +=2
	        self.direction = "down"

	if (self.direction == "up"):
	        self.y -=1 
	elif (self.direction == "down"):
	        self.y +=1

    def collide(self, room, player):
        
	if (player.x > self.x+room.relativex  and 
	player.x < self.x+room.relativex+self.w and 
	player.y > self.y+room.relativey and 
	player.y < self.y+room.relativey + self.h):
	    print "collision with assassin!"
	    return 2 
	else:
	    return 0 ## for game self.talker

		 
    def talk(self, screen,font):
        if self.talkcounter == 0:
            return
        
        if self.talkcounter > 2:
                self.talkcounter = 0
                return 
        talkover = 0
        while talkover == 0:
            pygame.display.update()
            if self.talkcounter == 1:
                screen.blit(font.render("I protect the archmage.", 8, (255,255,255)), (100,100))
            elif self.talkcounter == 2:
                screen.blit(font.render("He is my liege.", 8, (255,255,255)), (100,100))
            for event in pygame.event.get():
                if event.type == QUIT:
                    return
                elif event.type == KEYDOWN:
                    if event.key == K_z:
                        talkover = 1
                        self.talkcounter += 1
                

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from rng import *
from time import *

class BeholderBat(Gameobject):
    "Beholder"
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 48
        self.h = 48

        self.hitpoints = 3
        
	self.stimlib = Stateimagelibrary()	
        image = pygame.image.load('./pics/beholderbat1-48x48.bmp').convert()
        image.set_colorkey((255,0,0)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/beholderbat2-48x48.bmp').convert()
        image.set_colorkey((255,0,0)) 
	self.stimlib.addpicture(image)

	self.talkcounter = 0
	self.direction = "left"

    def draw(self, screen, room):
        self.stimlib.draw(screen, self.x+room.relativex,self.y+room.relativey)
	    
	     
    def update(self,room,player):
        sleep(.04) # FIX goblin sleep
	if room.collidewithenemy(self):
	    if (self.direction == "right"):
	        self.x -=6
	        self.direction = "left" 
	    elif (self.direction == "left"):
	        self.x +=6
	        self.direction = "right"
	    elif (self.direction == "down"):
	        self.y -=6
	        self.direction = "up" 
	    elif (self.direction == "up"):
	        self.y +=6
	        self.direction = "down"

	if player.x+28-room.relativex < self.x:
		self.x -= 3
		self.direction = "left"
	if player.x-28-room.relativex > self.x:
		self.direction = "right"
		self.x += 3	
	if player.y+10-room.relativey < self.y:
		self.direction = "up"
		self.y -= 3
	if player.y-10-room.relativey > self.y:
		self.direction = "down"
		self.y += 3

    def collide(self, room, player):
        # FIX BUG
        #print 'gameobject x=%d y=%d player x=%d y=%d' % (self.x,self.y,player.x-room.relativex,player.y-room.relativey)
	if (player.x-room.relativex > self.x-self.w  and 
	player.x-room.relativex < self.x+self.w+self.w and 
	player.y-room.relativey > self.y-self.h and 
	player.y-room.relativey < self.y + self.h +self.h):
	    #print "collision with Game Object!"
	    return 1 
	else:
	    return 0 ## for game self.talker


    def fight(self,room,player):
        self.fightcounter = 1
        o = player.collidewithenemyweapon(room,self)
        if o:
            player.hitwithenemyweapon(RNG().rollbeholderbatzap())

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from rng import *
from time import *

class BeholderGlassSummoner(Gameobject):
    "Beholder"
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 60 
        self.h = 48

        self.hitpoints = 10
        
	self.stimlib = Stateimagelibrary()	
        image = pygame.image.load('./pics/beholder1-48x48.bmp').convert()
        image.set_colorkey((255,0,0)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/beholder2-48x48.bmp').convert()
        image.set_colorkey((255,0,0)) 
	self.stimlib.addpicture(image)
        image = pygame.image.load('./pics/beholder3-48x48.bmp').convert()
        image.set_colorkey((255,0,0)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/beholder4-48x48.bmp').convert()
        image.set_colorkey((255,0,0)) 
	self.stimlib.addpicture(image)
        image = pygame.image.load('./pics/beholder5-48x48.bmp').convert()
        image.set_colorkey((255,0,0)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/beholder6-48x48.bmp').convert()
        image.set_colorkey((255,0,0)) 
	self.stimlib.addpicture(image)
        image = pygame.image.load('./pics/beholder7-48x48.bmp').convert()
        image.set_colorkey((255,0,0)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/beholder8-48x48.bmp').convert()
        image.set_colorkey((255,0,0)) 
	self.stimlib.addpicture(image)
        image = pygame.image.load('./pics/beholder9-48x48.bmp').convert()
        image.set_colorkey((255,0,0)) 
	self.stimlib.addpicture(image)
        image = pygame.image.load('./pics/beholder10-48x48.bmp').convert()
        image.set_colorkey((255,0,0)) 
	self.stimlib.addpicture(image)
        image = pygame.image.load('./pics/beholder11-48x48.bmp').convert()
        image.set_colorkey((255,0,0)) 
	self.stimlib.addpicture(image)
        image = pygame.image.load('./pics/beholder12-48x48.bmp').convert()
        image.set_colorkey((255,0,0)) 
	self.stimlib.addpicture(image)
        image = pygame.image.load('./pics/beholder13-48x48.bmp').convert()
        image.set_colorkey((255,0,0)) 
	self.stimlib.addpicture(image)
        image = pygame.image.load('./pics/beholder14-48x48.bmp').convert()
        image.set_colorkey((255,0,0)) 
	self.stimlib.addpicture(image)

	self.talkcounter = 0
	self.direction = "left"

    def draw(self, screen, room):
        self.stimlib.draw(screen, self.x+room.relativex,self.y+room.relativey)
	    
	     
    def update(self,room,player):
        sleep(.04) # FIX goblin sleep
	if room.collidewithenemy(self):
	    if (self.direction == "right"):
	        self.x -=6
	        self.direction = "left" 
	    elif (self.direction == "left"):
	        self.x +=6
	        self.direction = "right"
	    elif (self.direction == "down"):
	        self.y -=6
	        self.direction = "up" 
	    elif (self.direction == "up"):
	        self.y +=6
	        self.direction = "down"

	if player.x+28-room.relativex < self.x:
		self.x -= 3
		self.direction = "left"
	if player.x-28-room.relativex > self.x:
		self.direction = "right"
		self.x += 3	
	if player.y+10-room.relativey < self.y:
		self.direction = "up"
		self.y -= 3
	if player.y-10-room.relativey > self.y:
		self.direction = "down"
		self.y += 3

    def collide(self, room, player):
        # FIX BUG
        #print 'gameobject x=%d y=%d player x=%d y=%d' % (self.x,self.y,player.x-room.relativex,player.y-room.relativey)
	if (player.x-room.relativex > self.x-self.w  and 
	player.x-room.relativex < self.x+self.w+self.w and 
	player.y-room.relativey > self.y-self.h and 
	player.y-room.relativey < self.y + self.h +self.h):
	    #print "collision with Game Object!"
	    return 1 
	else:
	    return 0 ## for game self.talker


    def fight(self,room,player):
        self.fightcounter = 1
        o = player.collideiwthenemyweapon(room,self)
        if o:
            player.hitwithenemyweapon(RNG().rollbeholderzap())

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from rng import *
from time import *

class Beholder(Gameobject):
    "Beholder"
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 48
        self.h = 48

        self.hitpoints = 17 
        
	self.stimlib = Stateimagelibrary()	
	self.stimlibup = Stateimagelibrary()	
        image = pygame.image.load('./pics/beholder1-48x48.bmp').convert()
        image.set_colorkey((255,0,0)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/beholder2-48x48.bmp').convert()
        image.set_colorkey((255,0,0)) 
	self.stimlib.addpicture(image)
        image = pygame.image.load('./pics/beholder3-48x48.bmp').convert()
        image.set_colorkey((255,0,0)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/beholder4-48x48.bmp').convert()
        image.set_colorkey((255,0,0)) 
	self.stimlib.addpicture(image)
        image = pygame.image.load('./pics/beholder5-48x48.bmp').convert()
        image.set_colorkey((255,0,0)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/beholder6-48x48.bmp').convert()
        image.set_colorkey((255,0,0)) 
	self.stimlib.addpicture(image)
        image = pygame.image.load('./pics/beholder7-48x48.bmp').convert()
        image.set_colorkey((255,0,0)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/beholder8-48x48.bmp').convert()
        image.set_colorkey((255,0,0)) 
	self.stimlib.addpicture(image)
        image = pygame.image.load('./pics/beholder9-48x48.bmp').convert()
        image.set_colorkey((255,0,0)) 
	self.stimlib.addpicture(image)
        image = pygame.image.load('./pics/beholder10-48x48.bmp').convert()
        image.set_colorkey((255,0,0)) 
	self.stimlib.addpicture(image)
        image = pygame.image.load('./pics/beholder11-48x48.bmp').convert()
        image.set_colorkey((255,0,0)) 
	self.stimlib.addpicture(image)
        image = pygame.image.load('./pics/beholder12-48x48.bmp').convert()
        image.set_colorkey((255,0,0)) 
	self.stimlib.addpicture(image)
        image = pygame.image.load('./pics/beholder13-48x48.bmp').convert()
        image.set_colorkey((255,0,0)) 
	self.stimlib.addpicture(image)
        image = pygame.image.load('./pics/beholder14-48x48.bmp').convert()
        image.set_colorkey((255,0,0)) 
	self.stimlib.addpicture(image)

        image = pygame.image.load('./pics/beholderup1-48x48.bmp').convert()
        image.set_colorkey((255,0,0)) 
	self.stimlibup.addpicture(image)
        image = pygame.image.load('./pics/beholderup2-48x48.bmp').convert()
        image.set_colorkey((255,0,0)) 
	self.stimlibup.addpicture(image)

	self.talkcounter = 0
	self.direction = "left"

    def draw(self, screen, room):
	if self.direction == "up":
        	self.stimlibup.draw(screen, self.x+room.relativex,self.y+room.relativey)
        else:
		self.stimlib.draw(screen, self.x+room.relativex,self.y+room.relativey)
	    
	     
    def update(self,room,player):
        sleep(.04) # FIX goblin sleep
	if room.collidewithenemy(self):
	    if (self.direction == "right"):
	        self.x -=6
	        self.direction = "left" 
	    elif (self.direction == "left"):
	        self.x +=6
	        self.direction = "right"
	    elif (self.direction == "down"):
	        self.y -=6
	        self.direction = "up" 
	    elif (self.direction == "up"):
	        self.y +=6
	        self.direction = "down"

	if player.x+28-room.relativex < self.x:
		self.x -= 3
		self.direction = "left"
	if player.x-28-room.relativex > self.x:
		self.direction = "right"
		self.x += 3	
	if player.y+10-room.relativey < self.y:
		self.direction = "up"
		self.y -= 3
	if player.y-10-room.relativey > self.y:
		self.direction = "down"
		self.y += 3

    def collide(self, room, player):
        # FIX BUG
        #print 'gameobject x=%d y=%d player x=%d y=%d' % (self.x,self.y,player.x-room.relativex,player.y-room.relativey)
	if (player.x-room.relativex > self.x-self.w  and 
	player.x-room.relativex < self.x+self.w+self.w and 
	player.y-room.relativey > self.y-self.h and 
	player.y-room.relativey < self.y + self.h +self.h):
	    #print "collision with Game Object!"
	    return 1 
	else:
	    return 0 ## for game self.talker


    def fight(self,room,player):
        self.fightcounter = 1
        o = player.collidewithenemyweapon(room,self)
        if o:
            player.hitwithenemyweapon(RNG().rollbeholderzap())

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from time import *

class BlackKnight(Gameobject):
    "BlackKnight"
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 36
        self.h = 36 
	self.stimlibleft = Stateimagelibrary()	
	self.stimlibright = Stateimagelibrary()	
        image = pygame.image.load('./pics/knightdarkleft1-30x30.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/knightdarkleft2-30x30.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/knightdarkleft3-30x30.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	

        image = pygame.image.load('./pics/knightdarkright1-30x30.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/knightdarkright2-30x30.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/knightdarkright3-30x30.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	

	self.direction = "left"

    def draw(self, screen, room):
	if (self.direction == "left"):
            self.stimlibleft.draw(screen, self.x+room.relativex,self.y+room.relativey)
	elif (self.direction == "right"):
            self.stimlibright.draw(screen, self.x+room.relativex,self.y+room.relativey)
	    
	     
    def update(self,room):
        sleep(.01) # FIX darkkngith sleep
	if (random.randint(0,100) == 0 and self.direction == "left"):
	   self.direction = "right"
	elif (random.randint(0,100) == 0 and self.direction == "right"):
	   self.direction = "left"

	if (not self.collideobjectX(room)): 
	    if (self.direction == "left"):
	        self.x +=2
	        self.direction = "right" 
	    elif (self.direction == "right"):
	        self.x -=2
	        self.direction = "left"


	if (self.direction == "left"):
	        self.x -=1 
	elif (self.direction == "right"):
	        self.x +=1

    def collide(self, room, player):
	if (player.x > self.x+room.relativex  and 
	player.x < self.x+room.relativex+self.w and 
	player.y > self.y+room.relativey and 
	player.y < self.y+room.relativey + self.h):
	    print "collision with Dark Knight!"
	    if player.hit():
		return 1 
	    else:
	    	return 2 
	else:
	    return 0

		 

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random

class BlackKnightStanding(Gameobject):
    "BlackKnight"
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 36
        self.h = 36 
	self.stimlibleft = Stateimagelibrary()	
	self.stimlibright = Stateimagelibrary()	
        image = pygame.image.load('./pics/darknut1-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/darknut2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
	self.direction = "left"

    def draw(self, screen, room):
	if (self.direction == "left"):
            self.stimlibleft.draw(screen, self.x+room.relativex,self.y+room.relativey)
	elif (self.direction == "right"):
            self.stimlibright.draw(screen, self.x+room.relativex,self.y+room.relativey)
	    
	     
    def update(self,room):
	if (random.randint(0,100) == 0 and self.direction == "left"):
	   self.direction = "right"
	elif (random.randint(0,100) == 0 and self.direction == "right"):
	   self.direction = "left"
 
	if (self.direction == "left" and self.collide(room,self)):
	    self.x -= 1 
	elif (self.direction == "right" and self.collide(room,self)):
	    self.x += 1 


# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random

class Bombman(Gameobject):
    "Bombman"
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 36
        self.h = 36 

	self.stimlibburning = Stateimagelibrary()
	for i in range(0,15):	
        	image = pygame.image.load('./pics/bombburning1-24x24.bmp').convert()
        	image.set_colorkey((255,255,255)) 
		self.stimlibburning.addpicture(image)	
	for i in range(0,15):	
        	image = pygame.image.load('./pics/bombburning2-24x24.bmp').convert()
        	image.set_colorkey((255,255,255)) 
		self.stimlibburning.addpicture(image)	
	for i in range(0,15):	
        	image = pygame.image.load('./pics/bombburning3-24x24.bmp').convert()
        	image.set_colorkey((255,255,255)) 
		self.stimlibburning.addpicture(image)	
	for i in range(0,15):	
        	image = pygame.image.load('./pics/bomb1-24x24.bmp').convert()
        	image.set_colorkey((255,255,255)) 
		self.stimlibburning.addpicture(image)
	for i in range(0,5):	
        	image = pygame.image.load('./pics/bombred1-24x24.bmp').convert()
        	image.set_colorkey((255,255,255)) 
		self.stimlibburning.addpicture(image)
	for i in range(0,5):	
        	image = pygame.image.load('./pics/bomb1-24x24.bmp').convert()
        	image.set_colorkey((255,255,255)) 
		self.stimlibburning.addpicture(image)
	for i in range(0,5):	
        	image = pygame.image.load('./pics/bombred1-24x24.bmp').convert()
        	image.set_colorkey((255,255,255)) 
		self.stimlibburning.addpicture(image)
	for i in range(0,5):	
        	image = pygame.image.load('./pics/bomb1-24x24.bmp').convert()
        	image.set_colorkey((255,255,255)) 
		self.stimlibburning.addpicture(image)
	for i in range(0,5):	
        	image = pygame.image.load('./pics/bombred1-24x24.bmp').convert()
        	image.set_colorkey((255,255,255)) 
		self.stimlibburning.addpicture(image)
	for i in range(0,5):	
        	image = pygame.image.load('./pics/bomb1-24x24.bmp').convert()
        	image.set_colorkey((255,255,255)) 
		self.stimlibburning.addpicture(image)
	self.stimlibleft = Stateimagelibrary()	
	self.stimlibright = Stateimagelibrary()	
        image = pygame.image.load('./pics/bombmanleft1-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/bombmanleft1-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/bombmanleft1-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/bombmanleft2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/bombmanleft2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/bombmanleft2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/bombmanleft3-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/bombmanleft3-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/bombmanleft3-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/bombmanleft2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/bombmanleft2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/bombmanleft2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	

        image = pygame.image.load('./pics/bombman1-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/bombman1-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/bombman1-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/bombman2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/bombman2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/bombman2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/bombman3-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/bombman3-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/bombman3-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/bombman2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	

	self.direction = "left"

    def draw(self, screen, room):
	###print "self.direction=%s" % self.direction
	if (self.direction == "left"):
            self.stimlibleft.draw(screen, self.x+room.relativex,self.y+room.relativey)
	elif (self.direction == "right"):
            self.stimlibright.draw(screen, self.x+room.relativex,self.y+room.relativey)
	elif (self.direction == "burning"):    
            self.stimlibburning.draw(screen, self.x+room.relativex,self.y+room.relativey)
	    if self.stimlibburning.index >= self.stimlibburning.max:
	    	room.removeobject(self)
	    
	     
    def update(self,room):
	#print "self.direction=%s" % self.direction
	
	if self.direction == "burning":
		return

	if (random.randint(0,100) == 0 and self.direction == "left"):
	   self.direction = "right"
	elif (random.randint(0,100) == 0 and self.direction == "right"):
	   self.direction = "left"

	if (not self.collideobjectX(room)): 
	    if (self.direction == "left"):
	        self.x +=2
	        self.direction = "right" 
	    elif (self.direction == "right"):
	        self.x -=2
	        self.direction = "left"


	if (self.direction == "left"):
	        self.x -=1 
	elif (self.direction == "right"):
	        self.x +=1

    def collide(self, room, player):
	if (player.x > self.x+room.relativex  and 
	player.x < self.x+room.relativex+self.w and 
	player.y > self.y+room.relativey and 
	player.y < self.y+room.relativey + self.h):
		print "collision with Bombman!"
	    ###if player.hit():## FIX player needs descending hearts in meter
       		self.direction = "burning"
	return 0 
	    #else:
	    #	return 2 
	#else:
	 #   return 0

		 

# Copyright (C) Johan Ceuppens 2010 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *

class Bomb(Gameobject):
    ""
    def __init__(self, xx,yy):
        Gameobject.__init__(self,xx,yy)
        self.w = 16 
        self.h = 16 
        self.image = pygame.image.load('./pics/bomb1-16x16.bmp').convert()
        self.image.set_colorkey((0,0,0)) 
   	self.counter = 0 


    def update(self,room):
	self.counter += 1
	j = 0
	if (self.counter > 50):
	    for i in room.gameobjects:
		if (i == self):
		    l = 0
		    for k in room.gameobjects: 
			if i != k and k and k.collideobjectXY(room):
			    room.gameobjects[l] = None
			l += 1    	
		    room.gameobjects[j] = None 
		    return
	    	j += 1 

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from time import *
from rng import *

class Bow1(Gameobject):
    ""
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 50
        self.h = 50
	self.stimlib = Stateimagelibrary()		
        image = pygame.image.load('./pics/bow1-36x36.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlib.addpicture(image)	
	self.hitpoints = 1000000000
	self.id = "longbow"

    def draw(self, screen, room):
        self.stimlib.draw(screen, self.x+room.relativex,self.y+room.relativey)
	
    def update(self,room,player):
	1

    def pickup(self, player):
        #if self.collidepickup(room, player):
        #room.removeobject(self)
        return 8 # FIX 1 is value for pickupid in Game class

    def collidepickup(self, room, player):
        #print 'keyx=%d keyy=%d playerx=%d playery=%d' % (self.x,self.y,player.x-room.relativex,player.y-room.relativey)
	if (player.x-room.relativex > self.x-self.w  and 
	player.x-room.relativex < self.x+self.w+self.w and
	player.y-room.relativey > self.y and 
	player.y-room.relativey < self.y+self.h):
	    return 3 
	else:
	    return 0 
    
    def collide(self, room, player):
	return 0

    def roll(self):
	return RNG().rollbow()

# Copyright (C) Johan Ceuppens 2010 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *

class Box(Gameobject):
    "Box"
    def __init__(self, xx,yy,ww,hh):
        Gameobject.__init__(self,xx,yy)
        self.w = ww
        self.h = hh
        self.hitpoints = 100000000 #FIX else wall/floor disappears
        #FIX is in base class self.image = pygame.image.load('./pics/.bmp').convert()
        #self.image.set_colorkey((0,0,0)) 

    def setimage(self, imagefilename,r,g,b):
        self.image = pygame.image.load(imagefilename).convert()
        self.image.set_colorkey((r,g,b)) 

    def collide(self, room, player):
	if (player.x-room.relativex >= self.x  and 
	player.x-room.relativex <= self.x+self.w and 
	player.y+player.h-room.relativey >= self.y+self.h and #FIXED +self.h
	player.y-room.relativey <= self.y):
	    #print "collision in box!"	
	    return 4 #FIXME1 check for previous return 2
	else:
	    return 0


##    def fallcollide(self, room, player):
##        # FIX BUG
##        print 'box x=%d y=%d player x=%d y=%d' % (self.x,self.y,player.x-room.relativex,player.y-room.relativey)
##	if (player.y-room.relativey+player.h+1 > self.y and 
##            player.y-room.relativey+player.h+1 < self.y+self.h):
##	    print "collision with Game Object box!"
##	    return 1 
##	else:
##	    return 0 ## for game self.talker

    def collideboxes(self, room, entityorbox):
       if (entityorbox.x > self.x  and 
	entityorbox.x < self.x+self.w and 
	entityorbox.y+entityorbox.h > self.y and #FIXED +self.h
	entityorbox.y < self.y):
	    #print "collision in box!"	
	    return 2 #FIXME1 check for previous return 2
       else:
	    return 0

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from rng import *

class BroadSword(Gameobject):
    "Ruby Sword"
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 36
        self.h = 36
	self.stimlib = Stateimagelibrary()		
        image = pygame.image.load('./pics/taskbar-defaultsword1-32x32.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)	
	

    def draw(self, screen, room):
        self.stimlib.draw(screen, self.x+room.relativex,self.y+room.relativey)
	
	     
    def update(self,room,player):
	1

    def pickup(self, room):
        room.removeobject(self)
	return 5

    def collide(self, room, player):
        ###print 'gameobject x=%d y=%d player x=%d y=%d' % (self.x,self.y,player.x-room.relativex,player.y-room.relativey)
	return 5 

    def roll(self):
	return RNG().rollbroadsword()

# Copyright (C) Johan Ceuppens 2010 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *

class Dungeonbrokenwall(Gameobject):
    ""
    def __init__(self, xx,yy):
        Gameobject.__init__(self,xx,yy)
        self.w = 48 
        self.h = 48
        self.image = pygame.image.load('./pics/brokenwall-48x48.bmp').convert()
        self.image.set_colorkey((0,0,0)) 


# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from rng import *
from time import *
from math import *

class Bullfrog2(Gameobject):
    "Bullfrog"
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 100
        self.h = 100
        self.theta = 0
        self.PI = 3.14152829
        self.hitpoints = 5
        
	self.stimlibleft = Stateimagelibrary()	
	self.stimlibright = Stateimagelibrary()	
	self.stimlibdown = Stateimagelibrary()	
	self.stimlibup = Stateimagelibrary()	
        image = pygame.image.load('./pics/bullfrog2.1-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.1-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.1-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.1-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.2-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.2-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.2-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.2-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.3-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.3-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.3-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.3-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.4-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.4-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.4-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.4-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.3-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.3-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.3-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.3-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.2-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.2-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.2-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.2-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	
	self.talkcounter = 0
	self.direction = "left"

        self.flag = 1
        
    def draw(self, screen, room):
        self.stimlibleft.draw(screen, self.x,self.y)
	     
    def update(self,room,player):
        if self.y < 17*17 and self.flag:
            self.y = self.x*self.x/30
            self.x += 1
##        if abs(self.y-200) < 20:
##            self.x = 0
##            self.flag = 0
####            if self.flag == 1:
##                self.flag = 0
##            elif self.flag == 0:
##                self.flag = 1
##        if self.y >= 20*20:
##            if self.x >= 20 or self.y == 20*20:
##                self.x = 0
##                
##            self.y = -self.x*self.x/30+200
##            self.x += 1
            #self.flag = 1
##        if self.y > 200 and self.flag:
##             self.flag = 0
##            
        self.theta -= .1
        
        if self.theta > self.PI/2:## or self.y < player.y:
            self.theta = 0
        self.y += sin(self.theta) * 1
      
        

    def collide(self, room, player):
        # FIX BUG FIXME2 collide in fight should overlap seriously with player
        #print 'gameobject x=%d y=%d player x=%d y=%d' % (self.x,self.y,player.x-room.relativex,player.y-room.relativey)
	if (player.x-room.relativex > self.x  and 
	player.x-room.relativex < self.x+self.w and 
	player.y-room.relativey > self.y and 
	player.y-room.relativey < self.y + self.h):
	    #print "collision with Game Object!"
	    return 1 
	else:
	    return 0 ## for game self.talker


    def fight(self,room,player):
        self.fightcounter = 1
        o = player.collidewithenemyweapon(room,self)
        if o:
            player.hitwithenemyweapon(RNG().rollbullfrog())

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from rng import *
from time import *
from math import *

class Bullfrog3(Gameobject):
    "Bullfrog 3"
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 100
        self.h = 100
        self.theta = 0
        self.PI = 3.14152829
        self.hitpoints = 5
        
	self.stimlibleft = Stateimagelibrary()	
	self.stimlibright = Stateimagelibrary()	
	self.stimlibdown = Stateimagelibrary()	
	self.stimlibup = Stateimagelibrary()	
        image = pygame.image.load('./pics/bullfrog2.1-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.1-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.1-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.1-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.2-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.2-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.2-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.2-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.3-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.3-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.3-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.3-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.4-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.4-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.4-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.4-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.3-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.3-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.3-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.3-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.2-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.2-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.2-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.2-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	
	self.talkcounter = 0
	self.direction = "left"

        self.flag = 1
        self.y = 17*17
        self.x = 17
        
    def draw(self, screen, room):
        self.stimlibleft.draw(screen, self.x,self.y)
	     
    def update(self,room,player):
        if self.y > 0 and self.flag:
            self.y = self.x*self.x
            self.x -= 1.5
      
        self.theta -= .1
        
        if self.theta > self.PI/2:## or self.y < player.y:
            self.theta = 0
        self.y += sin(self.theta) * 1
      
        

    def collide(self, room, player):
        # FIX BUG FIXME2 collide in fight should overlap seriously with player
        #print 'gameobject x=%d y=%d player x=%d y=%d' % (self.x,self.y,player.x-room.relativex,player.y-room.relativey)
	if (player.x-room.relativex > self.x  and 
	player.x-room.relativex < self.x+self.w and 
	player.y-room.relativey > self.y and 
	player.y-room.relativey < self.y + self.h):
	    #print "collision with Game Object!"
	    return 1 
	else:
	    return 0 ## for game self.talker


    def fight(self,room,player):
        self.fightcounter = 1
        o = player.collidewithenemyweapon(room,self)
        if o:
            player.hitwithenemyweapon(RNG().rollbullfrog())

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from rng import *
from time import *
from math import *

class Bullfrog4(Gameobject):
    "Bullfrog 4"
    def __init__(self,xx,yy,activationpixel):
	Gameobject.__init__(self, xx, yy)
        self.w = 100
        self.h = 100
        self.theta = 0
        self.PI = 3.14152829
        self.hitpoints = 5
        self.activationpixel = activationpixel
        
	self.stimlibleft = Stateimagelibrary()	
	self.stimlibright = Stateimagelibrary()	
	self.stimlibdown = Stateimagelibrary()	
	self.stimlibup = Stateimagelibrary()	
        image = pygame.image.load('./pics/bullfrog2.1-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.1-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.1-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.1-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.2-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.2-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.2-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.2-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.3-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.3-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.3-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.3-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.4-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.4-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.4-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.4-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.3-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.3-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.3-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.3-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.2-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.2-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.2-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.2-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	
	self.talkcounter = 0
	self.direction = "left"

        #self.flag = 1

        self.xx = 17
        self.yy = 17*17
        
    def draw(self, screen, room):
        if self.player.x-room.relativex > self.activationpixel:
            self.stimlibleft.draw(screen, self.xx+self.x,self.yy+self.y)
	     
    def update(self,room,player):
        self.player = player##NOTE
        if player.x-room.relativex < self.activationpixel:
            return
        
        if self.yy > 0:
            self.yy = self.xx*self.xx
            self.xx -= 1.5
      
        self.theta -= .1
        
        if self.theta > self.PI/2:## or self.y < player.y:
            self.theta = 0
        self.y += sin(self.theta) * 1
      
        if self.yy+self.y-room.relativey > 480 or self.yy+self.y-room.relativey < -100:
            room.removeobject(self)

    def collide(self, room, player):
        # FIX BUG FIXME2 collide in fight should overlap seriously with player
        #print 'gameobject x=%d y=%d player x=%d y=%d' % (self.x,self.y,player.x-room.relativex,player.y-room.relativey)
	if (player.x-room.relativex > self.x  and 
	player.x-room.relativex < self.x+self.w and 
	player.y-room.relativey > self.y and 
	player.y-room.relativey < self.y + self.h):
	    #print "collision with Game Object!"
	    return 1 
	else:
	    return 0 ## for game self.talker


    def fight(self,room,player):
        self.fightcounter = 1
        o = player.collidewithenemyweapon(room,self)
        if o:
            player.hitwithenemyweapon(RNG().rollbullfrog())

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from rng import *
from time import *
from math import *

class Bullfrog5(Gameobject):
    "Bullfrog 5"
    def __init__(self,xx,yy,activationpixel):
	Gameobject.__init__(self, xx, yy)
        self.w = 100
        self.h = 100
        self.theta = 0
        self.PI = 3.14152829
        self.hitpoints = 5
        
	self.stimlibleft = Stateimagelibrary()	
	self.stimlibright = Stateimagelibrary()	
	self.stimlibdown = Stateimagelibrary()	
	self.stimlibup = Stateimagelibrary()	
        image = pygame.image.load('./pics/bullfrog2.1-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.1-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.1-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.1-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.2-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.2-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.2-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.2-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.3-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.3-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.3-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.3-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.4-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.4-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.4-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.4-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.3-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.3-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.3-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.3-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.2-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.2-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.2-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.2-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	
	self.talkcounter = 0
	self.direction = "left"

        #self.flag = 1

        self.xx = 17
        self.yy = -17*17
        self.activationpixel = activationpixel
        
    def draw(self, screen, room):
        if self.player.x-room.relativex > self.activationpixel:
            self.stimlibleft.draw(screen, self.xx+self.x-room.relativey,self.yy+self.y-room.relativey)
	     
    def update(self,room,player):


        self.player = player##NOTE
        if player.x-room.relativex < self.activationpixel:
            return
        
        if self.yy < 0:
            self.yy = -self.xx*self.xx
            self.xx -= 1.5
      
        self.theta -= .1
        
        if self.theta > self.PI/2:## or self.y < player.y:
            self.theta = 0
        self.y += sin(self.theta) * 1
      
        if self.yy+self.y-room.relativey > 480 or self.yy+self.y-room.relativey < -100:
            room.removeobject(self)

    def collide(self, room, player):
        # FIX BUG FIXME2 collide in fight should overlap seriously with player
        #print 'gameobject x=%d y=%d player x=%d y=%d' % (self.x,self.y,player.x-room.relativex,player.y-room.relativey)
	if (player.x-room.relativex > self.x  and 
	player.x-room.relativex < self.x+self.w and 
	player.y-room.relativey > self.y and 
	player.y-room.relativey < self.y + self.h):
	    #print "collision with Game Object!"
	    return 1 
	else:
	    return 0 ## for game self.talker


    def fight(self,room,player):
        self.fightcounter = 1
        o = player.collidewithenemyweapon(room,self)
        if o:
            player.hitwithenemyweapon(RNG().rollbullfrog())

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from rng import *
from time import *
from math import *

class Bullfrog(Gameobject):
    "Bullfrog"
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 100
        self.h = 100
        self.theta = 0
        self.PI = 3.14152829
        self.hitpoints = 5
        
	self.stimlibleft = Stateimagelibrary()	
	self.stimlibright = Stateimagelibrary()	
	self.stimlibdown = Stateimagelibrary()	
	self.stimlibup = Stateimagelibrary()	
        image = pygame.image.load('./pics/bullfrog1-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog1-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog1-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog1-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog3-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog3-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog3-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog3-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog4-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog3-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog3-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog3-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog3-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	
        image = pygame.image.load('./pics/bullfrogright1-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/bullfrogright1-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/bullfrogright1-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/bullfrogright1-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/bullfrogright2-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/bullfrogright2-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/bullfrogright2-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/bullfrogright2-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/bullfrogright3-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/bullfrogright3-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/bullfrogright3-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/bullfrogright3-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/bullfrogright4-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/bullfrogright4-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/bullfrogright4-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/bullfrogright4-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/bullfrogright3-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/bullfrogright2-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/bullfrogright2-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/bullfrogright2-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/bullfrogright2-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)

	self.talkcounter = 0
	self.direction = "left"

    def draw(self, screen, room):
	if (self.direction == "left"):
            self.stimlibleft.draw(screen, self.x+room.relativex,self.y+room.relativey)
	elif (self.direction == "right"):
            self.stimlibright.draw(screen, self.x+room.relativex,self.y+room.relativey)
##	elif (self.direction == "down"):
##            self.stimlibdown.draw(screen, self.x+room.relativex,self.y+room.relativey)
##	elif (self.direction == "up"):
##            self.stimlibup.draw(screen, self.x+room.relativex,self.y+room.relativey)
##	    
	     
    def update(self,room,player):

        self.fall(room,player)
        
	if room.collidewithenemy(self):
	    if (self.direction == "right"):
	        self.x -=4
	        self.direction = "left" 
	    elif (self.direction == "left"):
	        self.x +=4
	        self.direction = "right"
##	    elif (self.direction == "down"):
##	        self.y -=4
##	        self.direction = "up" 
##	    elif (self.direction == "up"):
##	        self.y +=4
##	        self.direction = "down"

	if player.x+28-room.relativex < self.x:
		self.x -= 3
		self.direction = "left"
	if player.x-28-room.relativex > self.x:
		self.direction = "right"
		self.x += 3	
##	if player.y+10-room.relativey < self.y:
##		self.direction = "up"
##		self.y -= 2
##	if player.y-10-room.relativey > self.y:
##		self.direction = "down"
##		self.y += 2

        self.theta -= .1
        
        if self.theta > self.PI/2:## or self.y < player.y:
            self.theta = 0
        self.y += sin(self.theta) * 1
      
        

    def collide(self, room, player):
        # FIX BUG FIXME2 collide in fight should overlap seriously with player
        #print 'gameobject x=%d y=%d player x=%d y=%d' % (self.x,self.y,player.x-room.relativex,player.y-room.relativey)
	if (player.x-room.relativex > self.x  and 
	player.x-room.relativex < self.x+self.w and 
	player.y-room.relativey > self.y and 
	player.y-room.relativey < self.y + self.h):
	    #print "collision with Game Object!"
	    return 1 
	else:
	    return 0 ## for game self.talker


    def fall(self, room,player):
        for i in room.gameobjects:
	    if i != None and i != self and i.collideboxes(room, self):
#                print 'spider1 x=%d y=%d o  x=%d y=%d' % (self.x,self.y,i.x,i.y+i.h)
                
		return 1 # 1 FIXME
	self.y += 10
        return 0

    def fight(self,room,player):
        self.fightcounter = 1
        o = player.collidewithenemyweapon(room,self)
        if o:
            player.hitwithenemyweapon(RNG().rollbullfrog())

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from time import *

class Butterfly2(Gameobject):
    ""
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 16
        self.h = 16 
	self.stimlib = Stateimagelibrary()
        image = pygame.image.load('./pics/butterfly1-16x16.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/butterfly2-16x16.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/butterfly3-16x16.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/butterfly4-16x16.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlib.addpicture(image)

	self.direction = "left"

    def draw(self, screen, room):
        self.stimlib.draw(screen, self.x+room.relativex,self.y+room.relativey)    
	     
    def update(self,room):
        sleep(.005)
##        self.x-=1

        r = random.randint(0,4)
	if (r == 0):
	   self.direction = "right"
        if (r == 1):
	   self.direction = "left"
        if (r == 2):
	   self.direction = "up"
	if (r == 3):
	   self.direction = "down"

	if (not self.collideobjectX(room)): 
	    if (self.direction == "left"):
	        self.x +=2
	        self.direction = "right" 
	    elif (self.direction == "right"):
	        self.x -=2
	        self.direction = "left"

	if (not self.collideobjectY(room)): 
	    if (self.direction == "up"):
	        self.x +=2
	        self.direction = "down" 
	    elif (self.direction == "down"):
	        self.x -=2
	        self.direction = "up"


	if (self.direction == "left"):
	        self.x -=1 
	elif (self.direction == "right"):
	        self.x +=1
	elif (self.direction == "down"):
	        self.y +=1
	elif (self.direction == "up"):
	        self.y -=1
	        

    def collide(self, room, player):
	if (player.x > self.x+room.relativex  and 
	player.x < self.x+room.relativex+self.w and 
	player.y > self.y+room.relativey and 
	player.y < self.y+room.relativey + self.h):
	    print "collision with Butterfly!"
	return 0

		 

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from time import *

class Butterfly(Gameobject):
    ""
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 16
        self.h = 16 
	self.stimlib = Stateimagelibrary()
        image = pygame.image.load('./pics/butterfly1-16x16.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/butterfly2-16x16.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/butterfly3-16x16.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/butterfly4-16x16.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlib.addpicture(image)

	self.direction = "left"

    def draw(self, screen, room):
        self.stimlib.draw(screen, self.x+room.relativex,self.y+room.relativey)    
	     
    def update(self,room):
        sleep(.005)
##        self.x-=1
	if (random.randint(0,14) == 0 and self.direction == "left"):
	   self.direction = "right"
        if (random.randint(0,13) == 0 and self.direction == "right"):
	   self.direction = "left"
        if (random.randint(0,12) == 0 and self.direction == "down"):
	   self.direction = "up"
	if (random.randint(0,10) == 0 and self.direction == "up"):
	   self.direction = "down"

	if (not self.collideobjectX(room)): 
	    if (self.direction == "left"):
	        self.x +=2
	        self.direction = "right" 
	    elif (self.direction == "right"):
	        self.x -=2
	        self.direction = "left"

	if (not self.collideobjectY(room)): 
	    if (self.direction == "up"):
	        self.x +=2
	        self.direction = "down" 
	    elif (self.direction == "down"):
	        self.x -=2
	        self.direction = "up"


	if (self.direction == "left"):
	        self.x -=1 
	elif (self.direction == "right"):
	        self.x +=1
	elif (self.direction == "down"):
	        self.y +=1
	elif (self.direction == "up"):
	        self.y -=1
	        

    def collide(self, room, player):
	if (player.x > self.x+room.relativex  and 
	player.x < self.x+room.relativex+self.w and 
	player.y > self.y+room.relativey and 
	player.y < self.y+room.relativey + self.h):
	    print "collision with Butterfly!"
	return 0

		 

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from time import *
from math import *
from rng import *

class CaveSpider1(Gameobject):
    "Cave Spider 1" 
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 32
        self.h = 32
        self.hitpoints = 2
        
        self.yy = yy
    
        self.image = pygame.image.load('./pics/spiderleft1-48x48.bmp').convert()
        self.image.set_colorkey((0,0,255))
        self.image2 = pygame.image.load('./pics/spiderup1-48x48.bmp').convert()
        self.image2.set_colorkey((0,0,255)) 
	self.silkimage = pygame.image.load('./pics/silk-2x2.bmp').convert()
        self.silkimage.set_colorkey((0,0,255))
        self.hitimage = pygame.image.load('./pics/spiderleft1-48x48.bmp').convert()
        self.hitimage.set_colorkey((0,0,255))
        
	self.talkcounter = 0
	self.direction = "down"
        self.hitcounter = 0
        self.crawling = 1
        self.up = 0

    def draw(self, screen, room):
        if self.hitcounter > 0:
            screen.blit(self.hitimage, (self.x-40+room.relativex,self.y+room.relativey))
            return
        if self.crawling == 0:
            # Draw spider silk cord
            for i in range(self.yy,self.y):
                screen.blit(self.silkimage, (self.x-self.w/2+room.relativex,i+room.relativey))
	    
            screen.blit(self.image, (self.x-40+room.relativex,self.y+room.relativey))
	else:
            screen.blit(self.image2, (self.x-40+room.relativex,self.y+room.relativey))
	    
    def update(self,room,player):
        
        if abs(player.x-self.x-room.relativex) < 5:
            self.crawling = 0

        # movement in trees towards player
        if self.crawling:
            return
        # lowering to bite
        else:
            if self.up:
                self.y -= 6
                if self.y <= self.yy:
                    self.up = 0
                    self.crawling = 1
                return
            if self.y < 300:
                self.y += 6
            elif self.y >= 300:
                self.up = 1
                    
    def collide(self, room, player):
        # FIX BUG
        #print 'gameobject x=%d y=%d player x=%d y=%d' % (self.x,self.y,player.x-room.relativex,player.y-room.relativey)
	if (player.x-room.relativex > self.x-self.w  and 
	player.x-room.relativex < self.x+self.w+self.w and 
	player.y-room.relativey > self.y-self.h and 
	player.y-room.relativey < self.y + self.h +self.h):
	    print "collision with CaveSpider!"
	    return 1 
	else:
	    return 0 ## for game self.talker


    def collidewithsword(self, room, player):
        print 'CaveSpider x=%d y=%d player x=%d y=%d' % (self.x,self.y,player.x-room.relativex,player.y-room.relativey)
	if (player.x-room.relativex > self.x -self.w  and 
	player.x-room.relativex < self.x+self.w and 
	player.y-room.relativey > self.y -self.h and 
	player.y-room.relativey < self.y + self.h):
	    print "collision with Sword CaveSpider!"
	    self.hitcounter = 3
	    return 1 
	else:
	    return 0

    def fight(self,room,player,keydown = -1):
        1

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from time import *
from math import *
from rng import *
from cavespider1 import *

class CaveSpider2(CaveSpider1):
    "Cave Spider 1" 
    def __init__(self,xx,yy):
	CaveSpider1.__init__(self, xx, yy)

    def draw(self, screen, room):
        if self.hitcounter > 0:
            screen.blit(self.hitimage, (self.x-40+room.relativex,self.y+room.relativey))
            return
        if self.crawling == 0:
            # Draw spider silk cord
            for i in range(self.yy,self.y-48):
                screen.blit(self.silkimage, (self.x-self.w/2+room.relativex,i+room.relativey))
	    
            screen.blit(self.image, (self.x-40+room.relativex,self.y+room.relativey))
	else:
            screen.blit(self.image2, (self.x-40+room.relativex,self.y+room.relativey))
	    
    def update(self,room,player):


        # activation pixel

        if player.x-room.relativex < 2600 and player.y-room.relativey > 300:
            return
        
        if abs(player.x-self.x-room.relativex) < 5:
            self.crawling = 0

        # movement in trees towards player
        if self.crawling:
            return
        # lowering to bite
        else:
            if self.up:
                self.y -= 6
                if self.y <= self.yy:
                    self.up = 0
                    self.crawling = 1
                return
            if self.y < 300:
                self.y += 6
            elif self.y >= 300:
                self.up = 1
                    
    def collide(self, room, player):
        # FIX BUG
        #print 'gameobject x=%d y=%d player x=%d y=%d' % (self.x,self.y,player.x-room.relativex,player.y-room.relativey)
	if (player.x-room.relativex > self.x-self.w  and 
	player.x-room.relativex < self.x+self.w+self.w and 
	player.y-room.relativey > self.y-self.h and 
	player.y-room.relativey < self.y + self.h +self.h):
	    print "collision with CaveSpider!"
	    return 1 
	else:
	    return 0 ## for game self.talker


    def collidewithsword(self, room, player):
        print 'CaveSpider x=%d y=%d player x=%d y=%d' % (self.x,self.y,player.x-room.relativex,player.y-room.relativey)
	if (player.x-room.relativex > self.x -self.w  and 
	player.x-room.relativex < self.x+self.w and 
	player.y-room.relativey > self.y -self.h and 
	player.y-room.relativey < self.y + self.h):
	    print "collision with Sword CaveSpider!"
	    self.hitcounter = 3
	    return 1 
	else:
	    return 0

    def fight(self,room,player,keydown = -1):
        1

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from rng import *
from time import *
from math import *
from healingpotion import *

class Chest1(Gameobject):
    ""
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 36
        self.h = 36
        
        self.hitpoints = 1
		
        self.image = pygame.image.load('./pics/chest1-36x36.bmp').convert()
        self.image.set_colorkey((0,0,0)) 
	
        
    def draw(self, screen, room):
	screen.blit(self.image, (self.x+room.relativex,self.y+room.relativey))
	
    def update(self,room,player):
        if self.hitpoints <= 0:
            room.gameobjects.append(HealingPotion(self.x,self.y))

    

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from time import *

class Demon(Gameobject):
    "Demon"
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 36
        self.h = 36 
	self.stimlibleft = Stateimagelibrary()	
	self.stimlibright = Stateimagelibrary()
	self.stimlibup = Stateimagelibrary()	
	self.stimlibdown = Stateimagelibrary()	
        image = pygame.image.load('./pics/demon1-36x36.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	self.stimlibright.addpicture(image)
	self.stimlibup.addpicture(image)
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/demon1-36x36.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	self.stimlibright.addpicture(image)
	self.stimlibup.addpicture(image)
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/demon1-36x36.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	self.stimlibright.addpicture(image)
	self.stimlibup.addpicture(image)
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/demon1-36x36.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	self.stimlibright.addpicture(image)
	self.stimlibup.addpicture(image)
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/demon2-36x36.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	self.stimlibright.addpicture(image)
	self.stimlibup.addpicture(image)
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/demon2-36x36.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	self.stimlibright.addpicture(image)
	self.stimlibup.addpicture(image)
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/demon2-36x36.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	self.stimlibright.addpicture(image)
	self.stimlibup.addpicture(image)
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/demon2-36x36.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	self.stimlibright.addpicture(image)
	self.stimlibup.addpicture(image)
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/demon3-36x36.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	self.stimlibright.addpicture(image)
	self.stimlibup.addpicture(image)
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/demon3-36x36.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	self.stimlibright.addpicture(image)
	self.stimlibup.addpicture(image)
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/demon3-36x36.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	self.stimlibright.addpicture(image)
	self.stimlibup.addpicture(image)
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/demon3-36x36.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	self.stimlibright.addpicture(image)
	self.stimlibup.addpicture(image)
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/demon2-36x36.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	self.stimlibright.addpicture(image)
	self.stimlibup.addpicture(image)
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/demon2-36x36.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	self.stimlibright.addpicture(image)
	self.stimlibup.addpicture(image)
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/demon2-36x36.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	self.stimlibright.addpicture(image)
	self.stimlibup.addpicture(image)
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/demon2-36x36.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	self.stimlibright.addpicture(image)
	self.stimlibup.addpicture(image)
	self.stimlibdown.addpicture(image)
	
        self.direction = "north"
        
    def draw(self, screen, room):
	if (self.direction == "left"):
            self.stimlibleft.draw(screen, self.x+room.relativex,self.y+room.relativey)
	elif (self.direction == "right"):
            self.stimlibright.draw(screen, self.x+room.relativex,self.y+room.relativey)
	elif (self.direction == "up"):
            self.stimlibup.draw(screen, self.x+room.relativex,self.y+room.relativey)
	elif (self.direction == "down"):
            self.stimlibright.draw(screen, self.x+room.relativex,self.y+room.relativey)
	    
	     
    def update(self,room):
        #FIXME elif
        sleep(.01)
	if (random.randint(0,5000) == 0):# and self.direction == "left"):
	   self.direction = "right"
	if (random.randint(0,5000) == 0):# and self.direction == "right"):
	   self.direction = "left"
        if (random.randint(0,5000) == 0):# and self.direction == "up"):
	   self.direction = "down"
	if (random.randint(0,5000) == 0):# and self.direction == "down"):
	   self.direction = "up"

	if (not self.collideobjectX(room)): 
	    if (self.direction == "left"):
	        self.x +=2
	        self.direction = "right" 
	    elif (self.direction == "right"):
	        self.x -=2
	        self.direction = "left"

        if (not self.collideobjectY(room)): 
	    if (self.direction == "up"):
	        self.y +=2
	        self.direction = "down" 
	    elif (self.direction == "down"):
	        self.y -=2
	        self.direction = "up"

	if (self.direction == "left"):
	    self.x -=1 
	elif (self.direction == "right"):
	    self.x +=1
	elif (self.direction == "up"):
	    self.y -=1
	elif (self.direction == "down"):
	    self.y +=1

# Copyright (C) Johan Ceuppens 2010 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *

class Dungeondoor1(Gameobject):
    "door 1"
    def __init__(self, xx,yy,ww,hh):
        Gameobject.__init__(self,xx,yy)
        self.w = ww
        self.h = hh
        self.hitpoints = 100000000 #FIX else wall/floor disappears
        #FIX is in base class self.image = pygame.image.load('./pics/.bmp').convert()
        #self.image.set_colorkey((0,0,0)) 

        self.setimage('./pics/dungeondoor1.bmp',0,0,0)

    def setimage(self, imagefilename,r,g,b):
        self.image = pygame.image.load(imagefilename).convert()
        self.image.set_colorkey((r,g,b)) 

    def collideXY(self, room, player):
        for i in room.gameobjects:
	     if (player.y-room.relativey >= self.y  and 
	player.y-room.relativey <= self.y+self.h and
        player.x-room.relativex >= self.x  and 
	player.x-room.relativex <= self.x+self.w):
                    if room.inventorykey1:
        	            room.removeobject(self)
	            return 0
	return 0 

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *

class Dungeonentrance1(Gameobject):
    "Dungeon entrance 1"
    def __init__(self, xx,yy):
	Gameobject.__init__(self,xx,yy)	
	self.w = 200 
        self.h = 100 
        self.image = pygame.image.load('./pics/dungeon-entrance1-200x100.bmp').convert()
        self.image.set_colorkey((0,0,0)) 



# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *

class Dungeonentrance2(Gameobject):
    "Dungeon entrance 1"
    def __init__(self, xx,yy):
	Gameobject.__init__(self,xx,yy)	
	self.w = 70
        self.h = 70 
        self.image = pygame.image.load('./pics/dungeon-entrance2-48x48.bmp').convert()
        self.image.set_colorkey((0,0,0)) 

    def collide(self, room, player):
	if (player.x > self.x+room.relativex  and 
	player.x < self.x+room.relativex+self.w and 
	player.y > self.y+room.relativey and 
	player.y < self.y+room.relativey + self.h):
	    print "collision with Dungeon Entrance 2! x=%d y=%d" % (room.relativex,room.relativey) 
	    ###if player.hit():
	    return 3 ###NOTE 3 for dungeon walls and entrances bounc back ## 4 ?
	return 0

    ### NOTE: dungeon master key gets checked in game.py and this opens with return 2
    def pickup(self, room):
        ###room.removeobject(self)
	return 2

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from time import *

class Dungeonkey1(Gameobject):
    "Darknut"
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 50
        self.h = 50
	self.stimlib = Stateimagelibrary()		
        image = pygame.image.load('./pics/dungeonkey1-36x36.bmp').convert()
        image.set_colorkey((255,255,255)) 
	self.stimlib.addpicture(image)	
	self.hitpoints = 1000000000

    def draw(self, screen, room):
        self.stimlib.draw(screen, self.x+room.relativex,self.y+room.relativey)
	
	     
    def update(self,room,player):
	1

    def pickup(self, player):
        #if self.collidepickup(room, player):
        #room.removeobject(self)
        return 5 # FIX 1 is value for pickupid in Game class

    def collidepickup(self, room, player):
        #print 'keyx=%d keyy=%d playerx=%d playery=%d' % (self.x,self.y,player.x-room.relativex,player.y-room.relativey)
	if (player.x-room.relativex > self.x-self.w  and 
	player.x-room.relativex < self.x+self.w+self.w and
	player.y-room.relativey > self.y and 
	player.y-room.relativey < self.y+self.h):
	    return 3 
	else:
	    return 0 
    
    def collide(self, room, player):
	return 0

        

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random

class Dungeonkey2GohmaLair(Gameobject):
    "Darknut"
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 36
        self.h = 36
	self.stimlib = Stateimagelibrary()		
        image = pygame.image.load('./pics/dungeonkey1-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)	
	

    def draw(self, screen, room):
        self.stimlib.draw(screen, self.x+room.relativex,self.y+room.relativey)
	
	     
    def update(self,room):
	1

    def pickup(self, room):
        room.removeobject(self)
	return 4

    def collide(self, room, player):
	    return 0

        

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from time import *

class Dungeonmasterkey(Gameobject):
    "Darknut"
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 50
        self.h = 50
	self.stimlib = Stateimagelibrary()		
        image = pygame.image.load('./pics/dungeonmasterkey1-36x36.bmp').convert()
        image.set_colorkey((255,255,255)) 
	self.stimlib.addpicture(image)	
	self.hitpoints = 1000000000

    def draw(self, screen, room):
        self.stimlib.draw(screen, self.x+room.relativex,self.y+room.relativey)
	
	     
    def update(self,room,player):
	1

    def pickup(self, player):
        #if self.collidepickup(room, player):
        #room.removeobject(self)
        return 7 # FIX 1 is value for pickupid in Game class

    def collidepickup(self, room, player):
        #print 'keyx=%d keyy=%d playerx=%d playery=%d' % (self.x,self.y,player.x-room.relativex,player.y-room.relativey)
	if (player.x-room.relativex > self.x  and 
	player.x-room.relativex < self.x+self.w and 
	player.y-room.relativey > self.y and 
	player.y-room.relativey < self.y+self.h):
	    return 3 
	else:
	    return 0 
    
    def collide(self, room, player):
	return 0

        

# Copyright (C) Johan Ceuppens 2010 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *

class Dungeonstatue1(Gameobject):
    ""
    def __init__(self, xx,yy):
        Gameobject.__init__(self,xx,yy)
        self.w = 36 
        self.h = 36 
        self.image = pygame.image.load('./pics/dungeon-statue1-36x36.bmp').convert()
        self.image.set_colorkey((0,0,0)) 
    
    def collide(self, room, player):
	return 0

# Copyright (C) Johan Ceuppens 2010 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *

class Dungeonstatue2(Gameobject):
    ""
    def __init__(self, xx,yy):
        Gameobject.__init__(self,xx,yy)
        self.w = 48
        self.h = 92 
        self.image = pygame.image.load('./pics/dungeon-statue2-48x92.bmp').convert()
        self.image.set_colorkey((255,255,255)) 
    
    def collide(self, room, player):
	return 0

# Copyright (C) Johan Ceuppens 2010 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *

class Dungeonstatue3(Gameobject):
    ""
    def __init__(self, xx,yy):
        Gameobject.__init__(self,xx,yy)
        self.w = 48
        self.h = 92 
        self.image = pygame.image.load('./pics/dungeon-statue3-48x92.bmp').convert()
        self.image.set_colorkey((255,255,255)) 
    
    def collide(self, room, player):
	return 0

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *

class Dungeonwall(Gameobject):
    ""
    def __init__(self, xx,yy,ww,hh):
        Gameobject.__init__(self,xx,yy)
        self.w = ww 
        self.h = hh
    
    def draw(self, screen, room):
	1


    def collide(self, room, player):
	if (player.x > self.x+room.relativex  and 
	player.x < self.x+room.relativex+self.w and 
	player.y > self.y+room.relativey and 
	player.y < self.y+room.relativey + self.h):
	    print "collision with Dungeon Wall! x=%d y=%d" % (room.relativex,room.relativey) 
	    ###if player.hit():
	    return 3 # NOTE return 3 for dungeon wall
	    #else:
	    #	return 2 
	else:
	    return 0


# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from rng import *
from time import *
from math import *

class Fishman1(Gameobject):
    "Jumping Fishman"
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 72
        self.h = 72
        self.theta = 0
        self.PI = 3.14152829
        self.hitpoints = 5
        
	self.stimlibleft = Stateimagelibrary()	
	self.stimlibright = Stateimagelibrary()	
	self.stimlib = Stateimagelibrary()	
        image = pygame.image.load('./pics/fishmanleft1-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft1-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft1-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft1-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft2-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft2-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft2-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft2-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft3-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft3-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft3-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft3-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft4-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft4-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft4-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft4-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft3-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft3-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft3-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft3-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft2-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft2-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft2-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft2-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)

	image = pygame.image.load('./pics/fishmanright0-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/fishmanright0-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/fishmanright0-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/fishmanright0-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
        image = pygame.image.load('./pics/fishmanright1-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/fishmanright1-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/fishmanright1-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/fishmanright1-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/fishmanright2-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/fishmanright2-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/fishmanright2-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/fishmanright2-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/fishmanright3-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/fishmanright3-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/fishmanright3-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/fishmanright3-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/fishmanright3-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/fishmanright2-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/fishmanright2-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/fishmanright2-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/fishmanright2-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)


        image = pygame.image.load('./pics/fishman1-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman1-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman1-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman1-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman2-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman2-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman2-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman2-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman3-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman3-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman3-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman3-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman4-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman4-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman4-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman4-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman3-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman3-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman3-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman3-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman2-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman2-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman2-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman2-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	

	self.talkcounter = 0
	self.direction = "left"
        self.jumping = 1
        
    def draw(self, screen, room):
	if (self.direction == "left"):
            self.stimlibleft.draw(screen, self.x+room.relativex,self.y+room.relativey)
	elif (self.direction == "right"):
            self.stimlibright.draw(screen, self.x+room.relativex,self.y+room.relativey)
	elif self.direction == "down" or self.direction == "up":
            self.stimlib.draw(screen, self.x+room.relativex,self.y+room.relativey)
	     
    def update(self,room,player):

        if self.jumping:
            # FIXME
            self.direction = "up"
            if self.y < 100:
                self.jumping = 0
            else:
                self.y -= 8
                self.direction = "down"
                return
        else:
            self.y += 8
                        
        # FIX for crawling to the right on a platform
        box = room.collideboxeswithenemy(self)
	if box and self.y+self.h > box.y:
	    #if (self.direction == "right"):
            if self.x-room.relativex < player.x:
                self.direction = "right"
                self.x +=4
            elif self.x-room.relativex > player.x:
                self.direction = "left"
                self.x -= 4
	    self.y -= 8
	    
	else:
            self.x += 20
            box = room.collideboxeswithenemy(self)
            if not box:##self.direction == "left" or self.direction == "right":
                print '+++++++++++++++++++++123'
            # FIXself.jumping = 1
##	        self.direction = "left" 
##	    elif (self.direction == "left"):
##	        self.x +=4
##	        self.direction = "right"
##	    elif (self.direction == "down"):
##	        self.y -=4
##	        self.direction = "up" 
##	    elif (self.direction == "up"):
##	        self.y +=4
##	        self.direction = "down"
##
##	if player.x+28-room.relativex < self.x:
##		self.x -= 3
##		self.direction = "left"
##	if player.x-28-room.relativex > self.x:
##		self.direction = "right"
##		self.x += 3	
##	if player.y+10-room.relativey < self.y:
##		self.direction = "up"
##		self.y -= 2
##	if player.y-10-room.relativey > self.y:
##		self.direction = "down"
##		self.y += 2

        

    def collide(self, room, player):
        # FIX BUG
        #print 'gameobject x=%d y=%d player x=%d y=%d' % (self.x,self.y,player.x-room.relativex,player.y-room.relativey)
	if (player.x-room.relativex > self.x  and 
	player.x-room.relativex < self.x+self.w and 
	player.y-room.relativey > self.y and 
	player.y-room.relativey < self.y + self.h):
	    #print "collision with Game Object!"
	    return 1 
	else:
	    return 0 ## for game self.talker

    def collideboxes(self, room, entityorbox):
        # NOTE: that no relx rely from  map are needed
        #print 'gameobject x=%d y=%d entityorbox x=%d y=%d' % (self.x,self.y,entityorbox.x-room.relativex,entityorbox.y-room.relativey)
##	if (entityorbox.x > self.x  and 
##	entityorbox.x < self.x+self.w and
        print "collision with Fishman and box!"
	if (entityorbox.y > self.y and 
	entityorbox.y < self.y + self.h):
	    print "collision with Fishman and box!"
	    return 1 
	else:
	    return 0 ## for game self.talker


    def fight(self,room,player):
        self.fightcounter = 1
        o = player.collidewithenemyweapon(room,self)
        if o:
            player.hitwithenemyweapon(RNG().rollfishman())


    def collidewithenemy(self,room,entityorbox):
        if self.collideboxes(room, entityorbox):# NOTE the enemy is player above 
            return 1
        else:
            return 0

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


### Fishman who jumps down when collided with player


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from rng import *
from time import *
from math import *

class Fishman1(Gameobject):
    "Jumping Fishman"
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 72
        self.h = 72
        self.theta = 0
        self.PI = 3.14152829
        self.hitpoints = 5
        
	self.stimlibleft = Stateimagelibrary()	
	self.stimlibright = Stateimagelibrary()	
	self.stimlib = Stateimagelibrary()	
        image = pygame.image.load('./pics/fishmanleft1-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft1-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft1-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft1-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft2-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft2-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft2-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft2-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft3-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft3-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft3-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft3-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft4-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft4-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft4-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft4-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft3-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft3-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft3-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft3-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft2-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft2-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft2-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft2-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)

	image = pygame.image.load('./pics/fishmanright0-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/fishmanright0-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/fishmanright0-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/fishmanright0-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
        image = pygame.image.load('./pics/fishmanright1-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/fishmanright1-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/fishmanright1-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/fishmanright1-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/fishmanright2-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/fishmanright2-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/fishmanright2-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/fishmanright2-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/fishmanright3-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/fishmanright3-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/fishmanright3-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/fishmanright3-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/fishmanright3-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/fishmanright2-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/fishmanright2-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/fishmanright2-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/fishmanright2-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)


        image = pygame.image.load('./pics/fishman1-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman1-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman1-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman1-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman2-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman2-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman2-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman2-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman3-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman3-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman3-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman3-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman4-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman4-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman4-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman4-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman3-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman3-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman3-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman3-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman2-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman2-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman2-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman2-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	

	self.talkcounter = 0
	self.direction = "left"
        self.jumping = 1
        
    def draw(self, screen, room):
	if (self.direction == "left"):
            self.stimlibleft.draw(screen, self.x+room.relativex,self.y+room.relativey)
	elif (self.direction == "right"):
            self.stimlibright.draw(screen, self.x+room.relativex,self.y+room.relativey)
	elif self.direction == "down" or self.direction == "up":
            self.stimlib.draw(screen, self.x+room.relativex,self.y+room.relativey)
	     
    def update(self,room,player):

        if self.jumping:
            # FIXME
            self.direction = "up"
            if self.y < 100:
                self.jumping = 0
            else:
                self.y -= 8
                
                return
        else:
            self.y += 8
            self.direction = "down"        
        # FIX for crawling to the right on a platform
        box = room.collideboxeswithenemy(self)
	if box:
            if self.y+self.h > box.y:
                #if (self.direction == "right"):
                if self.x+room.relativex < player.x:
                    self.direction = "right"
                    self.x += 10
                    self.y -= 8
                elif self.x+room.relativex > player.x:
                    self.direction = "left"
                    self.x -= 10
                    self.y -= 8
                
            else:
                self.y += 8
        else:
            self.y += 8

    def collide(self, room, player):
        # FIX BUG
        #print 'gameobject x=%d y=%d player x=%d y=%d' % (self.x,self.y,player.x-room.relativex,player.y-room.relativey)
	if (player.x-room.relativex > self.x  and 
	player.x-room.relativex < self.x+self.w and 
	player.y-room.relativey > self.y and 
	player.y-room.relativey < self.y + self.h):
	    #print "collision with Game Object!"
	    return 1 
	else:
	    return 0 ## for game self.talker

    def collideboxes(self, room, entityorbox):
        # NOTE: that no relx rely from  map are needed
        #print 'gameobject x=%d y=%d entityorbox x=%d y=%d' % (self.x,self.y,entityorbox.x-room.relativex,entityorbox.y-room.relativey)
##	if (entityorbox.x > self.x  and 
##	entityorbox.x < self.x+self.w and
        
	if (entityorbox.y > self.y and 
	entityorbox.y < self.y + self.h):
	    print "collision with Fishman and box!"
	    return 1 
	else:
	    return 0 ## for game self.talker


    def fight(self,room,player):
        self.fightcounter = 1
        o = player.collidewithenemyweapon(room,self)
        if o:
            player.hitwithenemyweapon(RNG().rollfishman())


    def collidewithenemy(self,room,entityorbox):
        if self.collideboxes(room, entityorbox):# NOTE the enemy is player above 
            return 1
        else:
            return 0

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from rng import *
from time import *
from math import *

class Fishman1(Gameobject):
    "Jumping Fishman"
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 72
        self.h = 72
        self.theta = 0
        self.PI = 3.14152829
        self.hitpoints = 5
        
	self.stimlibleft = Stateimagelibrary()	
	self.stimlibright = Stateimagelibrary()	
	self.stimlib = Stateimagelibrary()	
        image = pygame.image.load('./pics/fishmanleft1-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft1-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft1-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft1-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft2-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft2-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft2-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft2-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft3-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft3-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft3-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft3-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft4-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft4-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft4-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft4-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft3-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft3-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft3-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft3-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft2-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft2-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft2-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft2-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)

	image = pygame.image.load('./pics/fishmanright0-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/fishmanright0-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/fishmanright0-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/fishmanright0-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
        image = pygame.image.load('./pics/fishmanright1-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/fishmanright1-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/fishmanright1-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/fishmanright1-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/fishmanright2-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/fishmanright2-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/fishmanright2-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/fishmanright2-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/fishmanright3-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/fishmanright3-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/fishmanright3-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/fishmanright3-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/fishmanright3-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/fishmanright2-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/fishmanright2-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/fishmanright2-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/fishmanright2-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)


        image = pygame.image.load('./pics/fishman1-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman1-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman1-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman1-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman2-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman2-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman2-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman2-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman3-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman3-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman3-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman3-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman4-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman4-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman4-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman4-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman3-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman3-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman3-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman3-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman2-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman2-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman2-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman2-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	

	self.talkcounter = 0
	self.direction = "left"
        self.jumping = 1
        
    def draw(self, screen, room):
	if (self.direction == "left"):
            self.stimlibleft.draw(screen, self.x+room.relativex,self.y+room.relativey)
	elif (self.direction == "right"):
            self.stimlibright.draw(screen, self.x+room.relativex,self.y+room.relativey)
	elif self.direction == "down" or self.direction == "up":
            self.stimlib.draw(screen, self.x+room.relativex,self.y+room.relativey)
	elif self.direction == "up" or self.direction == "north":
            self.stimlib.draw(screen, self.x+room.relativex,self.y+room.relativey)
	     
    def update(self,room,player):

        if self.jumping == 1:
            # FIXME
            self.direction = "up"
            if self.y < 100:
                self.jumping = 0
            else:
                self.y -= 8
                
                return
        elif self.jumping == 2:
            self.y -= 8
            if self.y < 270:
                self.jumping = 3
            return
        elif self.jumping == 3:
            self.y += 8
            return
        else:
            self.y += 8
            self.direction = "down"        
        # FIX for crawling to the right on a platform
        box = room.collideboxeswithenemy(self)
	if box:
            if self.y+self.h >= box.y:
                #if (self.direction == "right"):
                if self.x+room.relativex < player.x:
                    self.direction = "right"
                    self.x += 5
                    box2 = room.collideboxeswithenemy(self)
                    if box2:
                        print 'box2=%s' % box2
                        self.y -= 8
                elif self.x+room.relativex > player.x:
                    self.direction = "left"
                    self.x -= 5
                    box2 = room.collideboxeswithenemy(self)
                    if box2:
                        self.y -= 8
                else:
                    self.jumping = 2
        else:
            box2 = room.collideboxeswithenemy(self)
            if box2:
                self.y -= 8

    def collide(self, room, player):
        # FIX BUG
        #print 'gameobject x=%d y=%d player x=%d y=%d' % (self.x,self.y,player.x-room.relativex,player.y-room.relativey)
	if (player.x-room.relativex > self.x  and 
	player.x-room.relativex < self.x+self.w and 
	player.y-room.relativey > self.y and 
	player.y-room.relativey < self.y + self.h):
	    #print "collision with Game Object!"
	    return 1 
	else:
	    return 0 ## for game self.talker

    def collideboxes(self, room, entityorbox):
        # NOTE: that no relx rely from  map are needed
        #print 'gameobject x=%d y=%d entityorbox x=%d y=%d' % (self.x,self.y,entityorbox.x-room.relativex,entityorbox.y-room.relativey)
##	if (entityorbox.x > self.x  and 
##	entityorbox.x < self.x+self.w and
        
	if (entityorbox.x + entityorbox.w >= self.x and entityorbox.x <= self.x and
            entityorbox.y + entityorbox.h >= self.y and entityorbox.y <= self.y):# and
    #        entityorbox.y >= self.y):
	    print "collision with Fishman and box!"
	    return 1 
	else:
	    return 0 ## for game self.talker


    def fight(self,room,player):
        self.fightcounter = 1
        o = player.collidewithenemyweapon(room,self)
        if o:
            player.hitwithenemyweapon(RNG().rollfishman())


    def collidewithenemy(self,room,entityorbox):
        if self.collideboxes(room, entityorbox):# NOTE the enemy is player above 
            return 1
        else:
            return 0

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from rng import *
from time import *
from math import *

class Fishman2(Gameobject):
    "Jumping Fishman activated after relativey > X"
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 72
        self.h = 72
        self.theta = 0
        self.PI = 3.14152829
        self.hitpoints = 5
        
	self.stimlibleft = Stateimagelibrary()	
	self.stimlibright = Stateimagelibrary()	
	self.stimlib = Stateimagelibrary()	
        image = pygame.image.load('./pics/fishmanleft1-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft1-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft1-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft1-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft2-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft2-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft2-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft2-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft3-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft3-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft3-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft3-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft4-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft4-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft4-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft4-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft3-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft3-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft3-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft3-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft2-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft2-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft2-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/fishmanleft2-80x80.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)

	image = pygame.image.load('./pics/fishmanright0-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/fishmanright0-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/fishmanright0-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/fishmanright0-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
        image = pygame.image.load('./pics/fishmanright1-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/fishmanright1-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/fishmanright1-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/fishmanright1-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/fishmanright2-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/fishmanright2-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/fishmanright2-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/fishmanright2-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/fishmanright3-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/fishmanright3-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/fishmanright3-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/fishmanright3-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/fishmanright3-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/fishmanright2-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/fishmanright2-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/fishmanright2-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/fishmanright2-92x92.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)


        image = pygame.image.load('./pics/fishman1-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman1-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman1-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman1-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman2-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman2-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman2-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman2-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman3-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman3-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman3-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman3-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman4-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman4-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman4-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman4-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman3-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman3-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman3-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman3-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman2-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman2-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman2-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/fishman2-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	

	self.talkcounter = 0
	self.direction = "left"
        self.jumping = 1
        
    def draw(self, screen, room):
	if (self.direction == "left"):
            self.stimlibleft.draw(screen, self.x+room.relativex,self.y+room.relativey)
	elif (self.direction == "right"):
            self.stimlibright.draw(screen, self.x+room.relativex,self.y+room.relativey)
	elif self.direction == "down" or self.direction == "up":
            self.stimlib.draw(screen, self.x+room.relativex,self.y+room.relativey)
	elif self.direction == "up" or self.direction == "north":
            self.stimlib.draw(screen, self.x+room.relativex,self.y+room.relativey)
	     
    def update(self,room,player):

        # NOTE activation pixel
        if room.relativey < -1000:
            return

        if self.jumping == 1:
            # FIXME
            self.direction = "up"
            if self.y < 1250:#FIX fixed number for maproom 2_1
                self.jumping = 0
            else:
                self.y -= 8
                
                return
        elif self.jumping == 2:
            self.y -= 8
            if self.y < 1370:
                self.jumping = 3
            return
        elif self.jumping == 3:
            self.y += 8
            return
        else:
            self.y += 8
            self.direction = "down"        
        # FIX for crawling to the right on a platform
        box = room.collideboxeswithenemy(self)
	if box:
            if self.y+self.h >= box.y:
                #if (self.direction == "right"):
                if self.x+room.relativex < player.x:
                    self.direction = "right"
                    self.x += 5
                    box2 = room.collideboxeswithenemy(self)
                    if box2:
                        print 'box2=%s' % box2
                        self.y -= 8
                elif self.x+room.relativex > player.x:
                    self.direction = "left"
                    self.x -= 5
                    box2 = room.collideboxeswithenemy(self)
                    if box2:
                        self.y -= 8
                else:
                    self.jumping = 2
        else:
            box2 = room.collideboxeswithenemy(self)
            if box2:
                self.y -= 8

    def collide(self, room, player):
        # FIX BUG
        #print 'gameobject x=%d y=%d player x=%d y=%d' % (self.x,self.y,player.x-room.relativex,player.y-room.relativey)
	if (player.x-room.relativex > self.x  and 
	player.x-room.relativex < self.x+self.w and 
	player.y-room.relativey > self.y and 
	player.y-room.relativey < self.y + self.h):
	    #print "collision with Game Object!"
	    return 1 
	else:
	    return 0 ## for game self.talker

    def collideboxes(self, room, entityorbox):
        # NOTE: that no relx rely from  map are needed
        #print 'gameobject x=%d y=%d entityorbox x=%d y=%d' % (self.x,self.y,entityorbox.x-room.relativex,entityorbox.y-room.relativey)
##	if (entityorbox.x > self.x  and 
##	entityorbox.x < self.x+self.w and
        
	if (entityorbox.x + entityorbox.w >= self.x and entityorbox.x <= self.x and
            entityorbox.y + entityorbox.h >= self.y and entityorbox.y <= self.y):# and
    #        entityorbox.y >= self.y):
	    print "collision with Fishman and box!"
	    return 1 
	else:
	    return 0 ## for game self.talker


    def fight(self,room,player):
        self.fightcounter = 1
        o = player.collidewithenemyweapon(room,self)
        if o:
            player.hitwithenemyweapon(RNG().rollfishman())


    def collidewithenemy(self,room,entityorbox):
        if self.collideboxes(room, entityorbox):# NOTE the enemy is player above 
            return 1
        else:
            return 0

# Copyright (C) Johan Ceuppens 2010 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *

class Gameobject:
    "Game object"
    def __init__(self, xx,yy):
	self.x = xx 
        self.y = yy
	# default width and height 
        self.w = 48
        self.h = 48
        self.SCREENH = 640
        self.SCREENW = 480
        ## dungeon statue as default picture
        ## self.image = pygame.image.load('./pics/dungeon-statue1-36x36.bmp').convert()
        self.image = pygame.image.load('./pics/nopicture.bmp').convert()
        self.image.set_colorkey((0,0,0)) 
        self.hitpoints = 1
        # NOTE : decrease 1 hitpoint with default sword
        self.hitf = self.hit1
        
    def draw(self, screen, room):
        screen.blit(self.image,(self.x+room.relativex,self.y+room.relativey))
	    
	     
    def collidewithsword(self, room, player):
        #print 'gameobject x=%d y=%d player x=%d y=%d' % (self.x,self.y,player.x-room.relativex,player.y-room.relativey)
	if (player.x-room.relativex > self.x and#-self.w  and 
	player.x-room.relativex < self.x+self.w and 
	player.y-room.relativey > self.y and#-self.h and 
	player.y-room.relativey < self.y + self.h):
	    #print "collision with Game Object!"
	    return 1 
	else:
	    return 0

    def collide(self, room, player):
        if (player.x-room.relativex >= self.x  and 
	player.x-room.relativex <= self.x+self.w and 
	player.y+player.h-room.relativey >= self.y+self.h and #FIXED +self.h
	player.y-room.relativey <= self.y):
	    #print "collision in box!"	
	    return 4 #FIXME1 check for previous return 2
	else:
	    return 0

    def collideXX(self, room, player):
        if (player.x-room.relativex >= self.x  and 
	player.x-room.relativex <= self.x+self.w and
            player.y-room.relativey+player.h > self.y):
	    #print "+++++++++++++++++++++++++++++collision in box!"	
	    return 5 #FIXME1 check for previous return 2
	else:
	    return 0

    def collideX(self, room, player):
        if (player.x-room.relativex >= self.x  and 
	player.x-room.relativex <= self.x+self.w):# and
#            player.y-room.relativey < self.y):
	    #print "+++++++++++++++++++++++++++++collision in box!"	
	    return 5 #FIXME1 check for previous return 2
	else:
	    return 0

    def collideY(self, room, player):
        if (player.y-room.relativey >= self.y  and 
	player.y-room.relativey <= self.y+self.w):
	    #print "****************************collision in box!"	
	    return 5 #FIXME1 check for previous return 2
	else:
	    return 0

    def collideXY(self, room, player):
        if (player.y-room.relativey >= self.y  and 
	player.y-room.relativey <= self.y+self.h and
        player.x-room.relativex >= self.x  and 
	player.x-room.relativex <= self.x+self.w):
	    #print "****************************collision in box!"	
	    return 5 #FIXME1 check for previous return 2
	else:
	    return 0

    def collidebow(self, room, player):
        if (player.x-room.relativex >= self.x-350  and 
	player.x-room.relativex <= self.x+self.w+350 and 
	player.y+player.h-room.relativey >= self.y and #FIXED +self.h
	player.y-room.relativey <= self.y):
	    print "collision in bow!"	
	    return 4 #FIXME1 check for previous return 2
	else:
	    return 0
	
    def collideknife(self, room, player):
        if (player.x-room.relativex >= self.x-300  and 
	player.x-room.relativex <= self.x+self.w+300 and 
	player.y+player.h-room.relativey >= self.y and #FIXED +self.h
	player.y-room.relativey <= self.y):
	    print "collision in knife!"	
	    return 4 #FIXME1 check for previous return 2
	else:
	    return 0
	
    def fallcollide(self, room, player):
        # FIX BUG
        if (player.y-room.relativey+player.h >= self.y +self.h and 
            player.y-room.relativey <= self.y + self.h and
            player.x-room.relativex >= self.x and 
            player.x-room.relativex <= self.x+self.w):
	    #print "FALL collision with Game Object!"
	    return 1 
        else:
	    return 0 ## for game self.talker



    def collidepickup(self, room,player):
##        #print 'keyx=%d keyy=%d playerx=%d playery=%d' % (self.x,self.y,player.x-room.relativex,player.y-room.relativey)
##	if (player.x-room.relativex > self.x  and 
##	player.x-room.relativex < self.x+self.w and 
##	player.y-room.relativey > self.y and 
##	player.y-room.relativey < self.y+self.h):
##	    print "------------------pickup collision!"	
##	    return 3 
##	else:
	    return 0  
    
    def collideobjectX(self, room):
	for i in room.gameobjects:
	    if i != None:	
	        if (self.x > i.x  and 
		    self.x < i.x+i.w):
	            return 1 
	return 0

    def collideobjectY(self, room):
	for i in room.gameobjects:
	    if i != None:	
	        if (self.y > i.y  and 
		    self.y < i.y+i.h):
	            return 1 
	return 0
 
    def collideobjectXY(self, room,player):
	for i in room.gameobjects:
	    if i:		
	        if (self.x > i.x  and 
	 	    self.x < i.x+i.w and 
	            self.y > i.y and 
	            self.y < i.y+i.h):
	            return 1 
	return 0 
    
    def update(self,room,player):
	1

    def pickup(self, player):
        return 0

    def hit1(self):## NOTE decreases hitpoints
        self.hitpoints -= 1
        return self.hitpoints

    def hit2(self):## NOTE decreases hitpoints
        self.hitpoints -= 2
        return self.hitpoints

    def hitwithweapon(self,damage):
	if damage > 0:
            print 'enemy is hit!'
            self.hitpoints -= damage

    def fight(self,room,player):
	1
    
    def undomove(self):
	1

    # FIXME2
    def collidewithenemy(self,room,enemy):
        return None


##    def collideboxes(self, room, entityorbox):
##        if (entityorbox.x + entityorbox.w >= self.x and entityorbox.x <= self.x):# and
##    #        entityorbox.y >= self.y):
##	    print "collision with Gameobject and box!"
##	    return 1 
##	else:
##	    return 0

    def collideboxes(self, room, entityorbox):
        # NOTE: that no relx rely from  map are needed
        #print 'gameobject x=%d y=%d entityorbox x=%d y=%d' % (self.x,self.y,entityorbox.x-room.relativex,entityorbox.y-room.relativey)
##	if (entityorbox.x > self.x  and 
##	entityorbox.x < self.x+self.w and
        
##	if (entityorbox.x + entityorbox.w >= self.x and entityorbox.x <= self.x and
##            entityorbox.y + entityorbox.h >= self.y and entityorbox.y <= self.y):# and
##    #        entityorbox.y >= self.y):
##	    print "collision with gameobject and box!"
##	    return 1 
##	else:
	return 0 ## for game self.talker

#!/usr/local/bin/python
# Copyright (C) Johan Ceuppens 2011
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *

from maproom1 import *
from maproom2 import *
from maproom2_1 import *

from taskbar import *
from time import *
from inventory import *
from meter import *
from playerkattafighter import*
from playerlink import *

from inventorybow1 import *
from inventoryknife1 import *

class Game:
    "Main function"
    def __init__(self):
        pygame.init()
        pygame.font.init()
        screen = pygame.display.set_mode((640, 480))
        font = pygame.font.SysFont("Times", 14)
        font2 = pygame.font.SysFont("Coutier", 36)
        font3 = pygame.font.SysFont("Vera", 52)
        gameover = 0

        askplayers = 0 # NOTE: 2 Player flag
        
        blankimage = pygame.image.load('./pics/blank.bmp').convert()
        ## There are several title screens in the ./pics/ directory
        titleimage = pygame.image.load('./pics/titlescreen.bmp').convert()
        self.x = 0
        self.y = 0
        
        #self.room = Maproom2_1(-3400,-800)
        #self.room = Maproom2(100,0)
        self.room = Maproom1(0,0)
        heartmeter = Meter()
        player = PlayerLink(heartmeter)
##        selector = Selector(screen, font)
##
##        selector.select()
##        
##	heartmeter = Meter()
##	player = PlayerFighter(heartmeter)##default fighter class
##	if selector.askrace() == "Human":
##            if selector.askclass() == "Fighter":
##                player = PlayerHumanFighter(heartmeter)
##            elif selector.askclass() == "Magic User":
##                player = PlayerMagicUser(heartmeter)
##        if selector.askrace() == "Bugbear":
##            if selector.askclass() == "Fighter":
##                player = PlayerGnollFighter(heartmeter)
##        if selector.askrace() == "Katta":
##            if selector.askclass() == "Fighter":
##                player = PlayerKattaFighter(heartmeter)
##        if selector.askrace() == "Elven":
##            if selector.askclass() == "Fighter":
##                player = PlayerElfFighter(heartmeter)
##        if selector.askrace() == "Abeille":
##            if selector.askclass() == "Fighter":
##                player = PlayerAbeilleFighter(heartmeter)
##        
##        player2 = None
##
        pygame.key.set_repeat(10,100)
        self.keydown = 0
        
        self.taskbar = Taskbar(screen,font,player)
        self.talker = None
        gameflag = 0
        while gameover == 0:
            pygame.display.update()
            screen.blit(titleimage, (0,0))
            sleep(0.01)
            for event in pygame.event.get():
                if event.type == QUIT:
                    return
                elif event.type == KEYDOWN:
                    gameover = 1
                if event.type == pygame.MOUSEBUTTONDOWN:
                    gameover = 1

            
        gameover = 0
        while gameover == 0:
            player.h = 72 # NOTE: for ducking, FIXME 48
            sleep(0.01)
            for event in pygame.event.get():
                if event.type == QUIT:
                    return
                elif event.type == KEYDOWN:
            	    self.keydown = 1
                    # player 1 key controls
                    
                    if event.key == K_x:
                        if self.room.collide(player) == 4:# FIXME2
                            self.talker = self.room.talkto() 
                            print "self.talker=%s" % self.talker
##			if self.talker == None:
##                        	id = player.pickup(self.room)
##				if id == 5:
##		                	self.taskbar.setrubysword()
##					player.setrubysword()
                    elif event.key == K_z:
                        player.fight(self.room,self,player)
                    #elif event.key == K_SPACE:
                    #    player.fight(self.room,self,player)
##                    elif event.key == K_UP:
##                        self.room.movedown()    
                    elif event.key == K_DOWN:
                        self.keydown = 2
                        
                        #FIXME keydown = 2
                        #self.room.moveup()    
                    elif event.key == K_LEFT:
                        self.room.moveright()
                        self.room.direction = "left"
                        player.direction = "left"#FIXME
                    elif event.key == K_RIGHT:
                        self.room.moveleft()
                        self.room.direction = "right"
                        player.direction = "right"
                    elif event.key == K_UP:
                        roomnumber = self.room.exit(self)
                        self.chooseroom(roomnumber,font)
                        if roomnumber == 0:
                            
                            if self.room.fall(player) == 2:
                                player.jump(self.room)    
                           
                    elif event.key == K_i:
#                        self.level.gameover = 1
                      #FIXME  pygame.event.flush()
                        flag = 0
                        inventory = Inventory()
		
			##if Scrollinvisibility(0,0,0,0,"1","1").readkeys(None):
                        ##    inventory.additem(Inventoryscrollinvisibility())
                        if self.room.inventoryknife1 == 1:
                       		inventory.additem(Inventoryknife1())
			if self.room.inventorymasterkey == 1:
                       		1###FIX for key in inventory.additem(Inventorymasterkey())
                        if self.room.inventorykey1 == 1:
                       		1###FIX for key in inventory.additem(Inventorykey1())
                       	if self.room.inventorykey2 == 1:
                       		1###FIX for key in inventory
                       	if self.room.inventorybow1 == 1:
                                inventory.additem(Inventorybow1())
                       		###FIX for key in inventory
			while flag == 0:#NOTE1
                            sleep(0.01)
                            for event in pygame.event.get():
                                if event.type == QUIT:
                                    return

                                elif event.type == KEYDOWN:
                                    if event.key == K_LEFT:
                                        inventory.moveleft()
                                    elif event.key == K_RIGHT:
                                        inventory.moveright()
                                    elif event.key == K_z or event.key == K_x:
                                        self.room.inventoryitem = inventory.getitem(self.room.inventoryitem)
                                        if self.room.inventoryitem:
                                            self.room.inventoryitem.setintaskbar(self.taskbar)
                                        flag = 1


                                inventory.draw(screen)
                                pygame.display.update()
 
	    pickupid = self.room.pickup(player)
	    if pickupid:
                str = ""
		if pickupid == 5: # NOTE : key1 id
		    self.room.inventorykey1 = 1
		    str = "You found a key."
		    gameflag = 0
		elif pickupid == 6: # NOTE : masterkey id
		    #self.room.inventorymasterkey = 1
		    str = "You healed."
		    gameflag = 0
		    player.hitpoints = player.maxhitpoints
		elif pickupid == 7: # NOTE : masterkey id
		    self.room.inventorymasterkey1 = 1
		    str = "You found a key."
		    gameflag = 0
		elif pickupid == 8: # NOTE : masterkey id
		    self.room.inventorybow1 = 1
		    #player.setbow()
		    #taskbar.setbow()
		    str = "You found a bow."
		    gameflag = 0
		    #do not set automatically self.taskbar.setbow()
		else:
                    gameflag = 1
                while gameflag == 0:
                    pygame.key.set_repeat(1000,1000)
                    screen.blit(blankimage, (0,0))
                    self.taskbar.draw(self)
                    heartmeter.draw(screen)
                    self.room.draw(screen,player)
                    player.update(self.room)
                    self.taskbar.draw(self)
                    screen.blit(font3.render(str, 8, (255,255,255)), (10,100))
                    
                    pygame.display.update()
                    sleep(0.01)
                    for event in pygame.event.get():
                        if event.type == QUIT:
                            return
                        elif event.type == KEYDOWN:
                            if (event.key == K_x or
                                  event.key == K_z):
                                    gameflag = 1                       
                pygame.key.set_repeat(10,100)
#		elif pickupid == 2: ## NOTE: dungeonentrance 2 id opens with key 1
#                    if self.inventorykey1 == 1:
#                        self.room.removeentrance2()
#                elif pickupid == 3: # NOTE dungeon key 1 id
#                    self.inventorykey1 = 1
#                elif pickupid == 4: # NOTE dungeon key 2 id
#                    self.inventorykey2 = 1
#                elif pickupid == 5: # NOTE ruby sword id
#                    self.inventoryrubysword = 1
#                    self.taskbar.setrubysword()
                    
            if self.room.collide(player) == 1 or player.hitpoints <= 0: # NOTE: return 1 after player heartmeter runs out (player.hit)
        	endingimage = pygame.image.load('./pics/endingscreen.bmp').convert()
        	while gameover == 0:
	            	pygame.display.update()
        	    	screen.blit(endingimage, (0,0))
        	    	sleep(0.01)
            		for event in pygame.event.get():
                		if event.type == QUIT:
                    			return
                		elif event.type == KEYDOWN:
                    			gameover = 1
					return
                		if event.type == pygame.MOUSEBUTTONDOWN:
                    			gameover = 1
					return
				    
            #if self.room.collide(player) == 3 or self.room.collide(player) == 2:###Dungeon wall
	    
            #elif self.room.relativey > prevy:
            #    self.room.relativey -= abs(prevy-self.room.relativey)
                #self.room.undomoveX()
            if self.room.collidewithropes(player) == 2:
                
                while gameflag == 0:
                    sleep(0.01)
                    for event in pygame.event.get():
                        if event.type == QUIT:
                            return
                        elif event.type == KEYDOWN:
            	    
                            # player 1 key controls
                            ##player.draw(screen)
                            ##if event.key == K_z:
                             ##   player.fight(self.room)  
                            if event.key == K_UP:
                                if self.room.collidewithropes(player) == 2:
                                    self.room.movedown()   
                            elif event.key == K_DOWN:
##                              if at the end of the rope, have to jump off  
                                if self.room.collidewithropes(player) == 2:
                                    self.room.moveup()
                            elif event.key == K_RIGHT:
                                self.room.moveleft()
                                gameflag = 1    
                            elif event.key == K_LEFT:
                                self.room.moveright()
                                gameflag = 1
                            if event.key == K_z:
                                player.fight(self.room,self,player)
                            elif event.key == K_x:
                                gameflag = 1
                            
                    sleep(0.05)
                    self.room.draw(screen,player)
                    player.update(self.room)
                    player.drawclimbing(screen)
                    self.taskbar.draw(self)
                    heartmeter.draw(screen) 
                    pygame.display.update()
                    screen.blit(blankimage, (0,0))

            # update player (jump) before fall
            #if ((not (self.room.collideX(player) and self.room.collideY(player)))
            #    or
            if self.room.collideXY(player) == 5:
            	self.room.undomoveX()
        	self.room.undomoveX()
        	#self.room.undomoveX()
        	    
            self.room.draw(screen,player)
            player.update(self.room)
            f = self.room.fall(player)
            if f == 2:                
                #self.room.undomove()
                gameflag = 0
            elif f == 0:
                
                if self.room.relativey < self.room.h:
                    endingimage = pygame.image.load('./pics/endingscreen.bmp').convert()
                    while gameover == 0:
                            pygame.display.update()
                            screen.blit(endingimage, (0,0))
                            sleep(0.01)
                            for event in pygame.event.get():
                                    if event.type == QUIT:
                                            return
                                    elif event.type == KEYDOWN:
                                            gameover = 1
                                            return
                                    if event.type == pygame.MOUSEBUTTONDOWN:
                                            gameover = 1
                                            return
                                        #gameflag = 1
##
            
            #if self.room.relativey < prevy:
            #    self.room.relativey = prevy#abs(prevy-self.room.relativey)

            print 'room-player x=%d y=%d' % (self.room.relativex,self.room.relativey)
            
            if self.keydown == 1:
                self.keydown = 0
                player.draw(screen)
            elif self.keydown == 2:
                self.keydown = 2
                player.drawduck(screen)
                player.h = 32
            else:
                player.drawstatic(screen)
            
            #player.draw(screen)
	    
            # fight for enemies
            # remove dead game objects

	    ### Set player hitpoints in life bar
	    heartmeter.index = player.hitpoints

            for o in self.room.gameobjects:
                if o:
                    o.fight(self.room,player)
            for o in self.room.gameobjects:
                if o and o.hitpoints <= 0:
                    self.room.removeobject(o)

            if self.talker != None:
                self.talker.talk(screen,font2)

            self.taskbar.draw(self)
            heartmeter.draw(screen)
            
            pygame.display.update()
            screen.blit(blankimage, (0,0))
            


    def sethitf(self, hitf):
        for i in self.room.gameobjects:
            i.hitf = hitf

    def setxy(self,xx,yy):
        self.x = xx
        self.y = yy

    # NOTE: set x y in maproom1 and Game() will set it with game.x (self.x) etc. 
    def chooseroom(self, roomnumber,font):
        if (roomnumber == 0):
            return
        # NOTE: 1_X  woods around haunted castle
        elif (roomnumber == 1):
            self.talker = None
            self.room = Maproom1(self.x,self.y)
        # rooms of haunted castle    
        elif (roomnumber == 2):
            self.talker = None
            self.room = Maproom2(self.x,self.y)
        elif (roomnumber == 2.1):
            self.talker = None
            self.room = Maproom2_1(self.x,self.y)
        elif (roomnumber == 2.2):
            self.talker = None
            self.room = Maproom2_2(self.x,self.y)
        elif (roomnumber == 3):
            self.talker = None
            self.room = Maproom3(self.x,self.y)
        elif (roomnumber == 4):
            self.talker = None
            self.room = Maproom4(self.x,self.y)
        elif (roomnumber == 5):
            self.talker = None
            self.room = Maproom5(self.x,self.y)
        elif (roomnumber == 6):
            self.talker = None
            self.room = Maproom6(self.x,self.y)
        elif (roomnumber == 7):
            self.talker = None
            self.room = Maproom7(self.x,self.y)
        elif (roomnumber == 8):
            self.talker = None
            self.room = Maproom8(self.x,self.y)
        elif (roomnumber == 9):
            self.talker = None
            self.room = Maproom9(self.x,self.y)
        elif (roomnumber == 10):
            self.talker = None
            self.room = Maproom10(self.x,self.y)
        elif (roomnumber == 11):
            self.talker = None
            self.room = Maproom11(self.x,self.y)
        elif (roomnumber == 12):
            self.talker = None
            self.room = Maproom12(self.x,self.y)
        elif (roomnumber == 13):
            self.talker = None
            self.room = Maproom13(self.x,self.y)
        elif (roomnumber == 14):
            self.talker = None
            self.room = Maproom14(self.x,self.y)
        # set sword parameters
        #if self.room.inventoryrubysword:
        #    self.sethitf(self.room.gameobjects.hit2)
            
if __name__ == "__main__":
    foo = Game()




# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random

class Ghost1(Gameobject):
    "Ghost1"
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 36
        self.h = 36 
	self.stimlibleft = Stateimagelibrary()	
	self.stimlibright = Stateimagelibrary()	
        image = pygame.image.load('./pics/ghostleft1-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/ghostleft1-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/ghostleft1-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/ghostleft1-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/ghostleft2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/ghostleft2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/ghostleft2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/ghostleft2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/ghostleft1-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/ghostleft1-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/ghostleft1-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/ghostleft1-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/ghostleft2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/ghostleft2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/ghostleft2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/ghostleft2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	

        image = pygame.image.load('./pics/ghost1-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/ghost1-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/ghost1-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/ghost1-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/ghost2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/ghost2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/ghost2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/ghost2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/ghost1-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/ghost1-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/ghost1-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/ghost1-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/ghost2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/ghost2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/ghost2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/ghost2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	

	self.direction = "left"

    def draw(self, screen, room):
	if (self.direction == "left"):
            self.stimlibleft.draw(screen, self.x+room.relativex,self.y+room.relativey)
	elif (self.direction == "right"):
            self.stimlibright.draw(screen, self.x+room.relativex,self.y+room.relativey)
	    
	     
    def update(self,room):
	if (not self.collideobjectX(room)): 
	    if (self.direction == "left"):
	        self.x +=2
	        self.direction = "right" 
	    elif (self.direction == "right"):
	        self.x -=2
	        self.direction = "left"


	if (self.direction == "left"):
	        self.x -=1 
	elif (self.direction == "right"):
	        self.x +=1

    def collide(self, room, player):
	if (player.x > self.x+room.relativex  and 
	player.x < self.x+room.relativex+self.w and 
	player.y > self.y+room.relativey and 
	player.y < self.y+room.relativey + self.h):
	    print "collision with Ghost 1!"
	    if player.hit():
		return 1 
	    else:
	    	return 2 
	else:
	    return 0

		 

# Copyright (C) Johan Ceuppens 2011
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from math import *
from time import *

class GhostCircling2(Gameobject):
    "ghostcircling2 with non-relative x/y"
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
	self.i = 0 ## / medridians, / paralells
	self.j = 0###-2*3.14 ## / medridians, / paralells
        self.w = 48
        self.h = 48 
	self.stimlibleft = Stateimagelibrary()	
	self.stimlibright = Stateimagelibrary()	
        image = pygame.image.load('./pics/ghostwithlantern1-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/ghostwithlantern1-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/ghostwithlantern1-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/ghostwithlantern1-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/ghostwithlantern1-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/ghostwithlantern1-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/ghostwithlantern1-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/ghostwithlantern1-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)	

        image = pygame.image.load('./pics/ghostwithlantern1-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/ghostwithlantern1-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/ghostwithlantern1-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/ghostwithlantern1-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)	
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/ghostwithlantern1-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/ghostwithlantern1-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/ghostwithlantern1-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/ghostwithlantern1-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)	

	self.direction = "left"
	self.hitpoints = 100000000

###    def draw(self, screen, room):
###	if (self.direction == "left"):
###            self.stimlibleft.draw(screen, self.x+room.relativex,self.y+room.relativey)
###	elif (self.direction == "right"):
###            self.stimlibright.draw(screen, self.x+room.relativex,self.y+room.relativey)
	    
	     
    def update(self,room,player):
	1

    def collide(self, room, player):
	if (player.x > self.x+room.relativex  and 
	player.x < self.x+room.relativex+self.w and 
	player.y > self.y+room.relativey and 
	player.y < self.y+room.relativey + self.h):
	    print "collision with ghostwithlantern1!"
	    if player.hit():
		return 1 
	    else:
	    	return 2 
	else:
	    return 0

    def draw(self,screen,room):
	color = (255,0,0)
	self.PI = 3.14152829
	self.cx = 150
	self.cy = 60 
	self.cz = 100
	self.n = 100
	self.r = 100
	if self.j < self.n / 2:
		self.theta1 = self.j*2*self.PI / self.n - self.PI
		self.theta2 = (self.j+1)*2*self.PI / self.n - self.PI
		if self.i < self.n:
			self.theta3 = self.i * 2*self.PI / self.n
			x = cos(self.theta2)*cos(self.theta3) 
			y = sin(self.theta2)*sin(self.theta3)
			z = sin(self.theta2)
			self.x = x * self.r
			self.y = y * self.r
			###self.z *= self.r
		        self.stimlibleft.draw(screen, self.cx+self.x,self.cy+self.y)
                        #sleep(.05) # FIX ghost2 sleep
			###pygame.draw.line(pygame.display.get_surface(),color, (self.cx+self.x,self.cy+self.y),(self.cx+self.x,self.cy+self.y))
			self.i += .9 # FIX .5 
		else:
			self.i = 0
		self.j += .9 # FIX .1
	else:
		self.j = 0

		 

# Copyright (C) Johan Ceuppens 2011
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from math import *
from time import *

class GhostCircling(Gameobject):
    "ghostcircling"
    def __init__(self,xx,yy, centerx, centery):
	Gameobject.__init__(self, xx, yy)
	self.i = 0 ## / medridians, / paralells
	self.j = 0###-2*3.14 ## / medridians, / paralells
        self.w = 0 
        self.h = 0 

        self.cx = centerx
        self.cy = centery
        
	self.stimlibleft = Stateimagelibrary()	
	self.stimlibright = Stateimagelibrary()	
        image = pygame.image.load('./pics/ghostwithlantern1-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/ghostwithlantern1-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/ghostwithlantern1-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/ghostwithlantern1-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/ghostwithlantern1-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/ghostwithlantern1-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/ghostwithlantern1-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/ghostwithlantern1-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)	

        image = pygame.image.load('./pics/ghostwithlantern1-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/ghostwithlantern1-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/ghostwithlantern1-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/ghostwithlantern1-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)	
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/ghostwithlantern1-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/ghostwithlantern1-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/ghostwithlantern1-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/ghostwithlantern1-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)	

	self.direction = "left"
	self.hitpoints = 100000000

###    def draw(self, screen, room):
###	if (self.direction == "left"):
###            self.stimlibleft.draw(screen, self.x+room.relativex,self.y+room.relativey)
###	elif (self.direction == "right"):
###            self.stimlibright.draw(screen, self.x+room.relativex,self.y+room.relativey)
	    
	     
    def update(self,room,player):
	1

    def collide(self, room, player):
	if (player.x > self.x+room.relativex  and 
	player.x < self.x+room.relativex+self.w and 
	player.y > self.y+room.relativey and 
	player.y < self.y+room.relativey + self.h):
	    print "collision with ghostwithlantern1!"
	    if player.hit():
		return 1 
	    else:
	    	return 2 
	else:
	    return 0

    def draw(self,screen,room):
	color = (255,0,0)
	self.PI = 3.14152829
	 
	self.cz = 100
	self.n = 100
	self.r = 100
	if self.j < self.n / 2:
		self.theta1 = self.j*2*self.PI / self.n - self.PI
		self.theta2 = (self.j+1)*2*self.PI / self.n - self.PI
		if self.i < self.n:
			self.theta3 = self.i * 2*self.PI / self.n
			x = cos(self.theta2)*cos(self.theta3) 
			y = sin(self.theta2)*sin(self.theta3)
			z = sin(self.theta2)
			self.x = x * self.r
			self.y = y * self.r
			###self.z *= self.r
		        self.stimlibleft.draw(screen, self.cx+self.x+room.relativex,self.cy+self.y+room.relativey)
                        #sleep(.05) # FIX ghost2 sleep
			###pygame.draw.line(pygame.display.get_surface(),color, (self.cx+self.x,self.cy+self.y),(self.cx+self.x,self.cy+self.y))
			self.i += .9 # FIX .5 
		else:
			self.i = 0
		self.j += .9 # FIX .1
	else:
		self.j = 0

		 

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
from random import *

class GhostWandering(Gameobject):
    "Wandering Ghost"
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 0 
        self.h = 0 
	self.stimlibleft = Stateimagelibrary()	
	self.stimlibright = Stateimagelibrary()	
        image = pygame.image.load('./pics/ghostwithlantern1-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/ghostwithlantern1-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/ghostwithlantern1-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/ghostwithlantern1-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/ghostwithlantern1-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/ghostwithlantern1-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/ghostwithlantern1-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/ghostwithlantern1-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)	

        image = pygame.image.load('./pics/ghostwithlantern1-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/ghostwithlantern1-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/ghostwithlantern1-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/ghostwithlantern1-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)	
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/ghostwithlantern1-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/ghostwithlantern1-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/ghostwithlantern1-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/ghostwithlantern1-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)	

	self.direction = "left"

        self.hitpoints = 10000000000

    def draw(self, screen, room):
	if (self.direction == "left"):
            self.stimlibleft.draw(screen, self.x+room.relativex,self.y+room.relativey)
	elif (self.direction == "right"):
            self.stimlibright.draw(screen, self.x+room.relativex,self.y+room.relativey)
	    
	     
    def update(self,room,player):
	#if (not self.collideobjectX(room)):
        if (randint(0,100) == 0): 
	    if (self.direction == "left"):
	        self.x +=2
	        self.direction = "right" 
	    elif (self.direction == "right"):
	        self.x -=2
	        self.direction = "left"


	if (self.direction == "left"):
	        self.x -=1 
	elif (self.direction == "right"):
	        self.x +=1

    def collide(self, room, player):
	if (player.x > self.x+room.relativex  and 
	player.x < self.x+room.relativex+self.w and 
	player.y > self.y+room.relativey and 
	player.y < self.y+room.relativey + self.h):
	    print "collision with ghostwandering (1)!"
	    if player.hit():
		return 1 
	    else:
	    	return 2 
	else:
	    return 0

		 

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from rng import *
from time import *
from math import *

class Bullfrog5(Gameobject):
    "Bullfrog 5"
    def __init__(self,xx,yy,activationpixel):
	Gameobject.__init__(self, xx, yy)
        self.w = 100
        self.h = 100
        self.theta = 0
        self.PI = 3.14152829
        self.hitpoints = 5
        
	self.stimlibleft = Stateimagelibrary()	
	self.stimlibright = Stateimagelibrary()	
	self.stimlibdown = Stateimagelibrary()	
	self.stimlibup = Stateimagelibrary()	
        image = pygame.image.load('./pics/bullfrog2.1-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.1-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.1-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.1-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.2-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.2-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.2-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.2-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.3-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.3-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.3-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.3-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.4-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.4-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.4-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.4-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.3-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.3-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.3-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.3-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.2-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.2-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.2-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/bullfrog2.2-100x100.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	
	self.talkcounter = 0
	self.direction = "left"

        #self.flag = 1

        self.xx = 17
        self.yy = -17*17
        self.activationpixel = activationpixel
        
    def draw(self, screen, room):
        if self.player.x-room.relativex > self.activationpixel:
            self.stimlibleft.draw(screen, self.xx+self.x-room.relativey,self.yy+self.y-room.relativey)
	     
    def update(self,room,player):


        self.player = player##NOTE
        if player.x-room.relativex < self.activationpixel:
            return
        
        if self.yy < 0:
            self.yy = -self.xx*self.xx
            self.xx -= 1.5
      
        self.theta -= .1
        
        if self.theta > self.PI/2:## or self.y < player.y:
            self.theta = 0
        self.y += sin(self.theta) * 1
      
        if self.yy+self.y-room.relativey > 480 or self.yy+self.y-room.relativey < -100:
            room.removeobject(self)

    def collide(self, room, player):
        # FIX BUG FIXME2 collide in fight should overlap seriously with player
        #print 'gameobject x=%d y=%d player x=%d y=%d' % (self.x,self.y,player.x-room.relativex,player.y-room.relativey)
	if (player.x-room.relativex > self.x-self.w  and 
	player.x-room.relativex < self.x+self.w+self.w and 
	player.y-room.relativey > self.y and 
	player.y-room.relativey < self.y + self.h):
	    #print "collision with Game Object!"
	    return 1 
	else:
	    return 0 ## for game self.talker


    def fight(self,room,player):
        self.fightcounter = 1
        o = player.collidewithenemyweapon(room,self)
        if o:
            player.hitwithenemyweapon(RNG().rollbullfrog())

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from time import *

class Goblin1(Gameobject):
    "Goblin"
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 48
        self.h = 48

        self.hitpoints = 3
        
	self.stimlibdown = Stateimagelibrary()	
	self.stimlibup = Stateimagelibrary()	
        image = pygame.image.load('./pics/goblin1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)	
        image = pygame.image.load('./pics/goblin1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/goblin1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/goblin1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)

	image = pygame.image.load('./pics/goblin2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)	
        image = pygame.image.load('./pics/goblin2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/goblin2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/goblin2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)

        image = pygame.image.load('./pics/goblin1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)	
        image = pygame.image.load('./pics/goblin1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/goblin1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/goblin1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)
	
        image = pygame.image.load('./pics/goblin3-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)	
        image = pygame.image.load('./pics/goblin3-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/goblin3-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/goblin3-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)

        image = pygame.image.load('./pics/goblin2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)	
        image = pygame.image.load('./pics/goblin2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/goblin2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/goblin2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)

        image = pygame.image.load('./pics/goblinup1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/goblinup1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/goblinup1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/goblinup1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)

	image = pygame.image.load('./pics/goblinup2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/goblinup2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/goblinup2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/goblinup2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)

	image = pygame.image.load('./pics/goblinup3-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/goblinup3-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/goblinup3-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/goblinup3-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
        	
        image = pygame.image.load('./pics/goblinup2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/goblinup2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/goblinup2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/goblinup2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)

	self.talkcounter = 0
	self.direction = "down"

    def draw(self, screen, room):
	if (self.direction == "down"):
            self.stimlibdown.draw(screen, self.x+room.relativex,self.y+room.relativey)
	elif (self.direction == "up"):
            self.stimlibup.draw(screen, self.x+room.relativex,self.y+room.relativey)
	    
	     
    def update(self,room):
        sleep(.04) # FIX goblin sleep
	
	if (not self.collideobjectY(room)): 
	    if (self.direction == "down"):
	        self.y -=2
	        self.direction = "up" 
	    elif (self.direction == "up"):
	        self.y +=2
	        self.direction = "down"

	if (self.direction == "up"):
	        self.y -=1 
	elif (self.direction == "down"):
	        self.y +=1

    def collide(self, room, player):
        # FIX BUG
        print 'goblin x=%d y=%d player x=%d y=%d' % (self.x,self.y,player.x-room.relativex,player.y)
	if (player.x-room.relativex > self.x  and 
	player.x-room.relativex < self.x+self.w and 
	player.y-room.relativey > self.y and 
	player.y-room.relativey < self.y + self.h):
	    print "collision with Goblin!"
	    return 1 
	else:
	    return 0 ## for game self.talker

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from rng import *
from time import *

class Goblin2(Gameobject):
    "Goblin"
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 48
        self.h = 48

        self.hitpoints = 3
        
	self.stimlibleft = Stateimagelibrary()	
	self.stimlibright = Stateimagelibrary()	
        image = pygame.image.load('./pics/goblin2left1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/goblin2left2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
        image = pygame.image.load('./pics/goblin2right1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/goblin2right2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)

	self.talkcounter = 0
	self.direction = "left"

    def draw(self, screen, room):
	if (self.direction == "left"):
            self.stimlibleft.draw(screen, self.x+room.relativex,self.y+room.relativey)
	elif (self.direction == "right"):
            self.stimlibright.draw(screen, self.x+room.relativex,self.y+room.relativey)
	    
	     
    def update(self,room,player):
        sleep(.04) # FIX goblin sleep
#	if (not self.collideobjectY(room)): 
#	    if (self.direction == "right"):
#	        self.x -=2
#	        self.direction = "left" 
#	    elif (self.direction == "left"):
#	        self.x +=2
#	        self.direction = "right"

	if player.x < self.x:
		self.x -= 2
	elif player.x > self.x+self.w:
		self.x += 2	
	if player.y < self.y:
		self.y -= 2
	elif player.y > self.y+self.h:
		self.y += 2	

	if (self.direction == "left"):
	        self.x -=2
	elif (self.direction == "right"):
	        self.x +=2

    def fight(self,room,player):
        self.fightcounter = 1
        #print 'fight'
        o = player.collidesword(room,self)
        #print 'fight %s' % o
        if o:
            print 'player is hit!'
            player.hitwithsword(RNG().rollgoblinknife())

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from rng import *
from time import *

class Goblin3(Gameobject):
    "Goblin"
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 48
        self.h = 48

        self.hitpoints = 3
        
	self.stimlibleft = Stateimagelibrary()	
	self.stimlibright = Stateimagelibrary()	
	self.stimlibdown = Stateimagelibrary()	
	self.stimlibup = Stateimagelibrary()	
        image = pygame.image.load('./pics/goblin2left1-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/goblin2left2-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
        image = pygame.image.load('./pics/goblin2right1-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/goblin2right2-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
        image = pygame.image.load('./pics/goblin2right1-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibdown.addpicture(image)	
        image = pygame.image.load('./pics/goblin2right2-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibdown.addpicture(image)
        image = pygame.image.load('./pics/goblin2right1-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibup.addpicture(image)	
        image = pygame.image.load('./pics/goblin2right2-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibup.addpicture(image)

	self.talkcounter = 0
	self.direction = "left"

    def draw(self, screen, room):
	if (self.direction == "left"):
            self.stimlibleft.draw(screen, self.x+room.relativex,self.y+room.relativey)
	elif (self.direction == "right"):
            self.stimlibright.draw(screen, self.x+room.relativex,self.y+room.relativey)
	elif (self.direction == "down"):
            self.stimlibdown.draw(screen, self.x+room.relativex,self.y+room.relativey)
	elif (self.direction == "up"):
            self.stimlibup.draw(screen, self.x+room.relativex,self.y+room.relativey)
	    
	     
    def update(self,room,player):
        ###sleep(.04) # FIX goblin sleep
	if room.collidewithenemy(self):
	    if (self.direction == "right"):
	        self.x -=4
	        self.direction = "left" 
	    elif (self.direction == "left"):
	        self.x +=4
	        self.direction = "right"
	    elif (self.direction == "down"):
	        self.y -=4
	        self.direction = "up" 
	    elif (self.direction == "up"):
	        self.y +=4
	        self.direction = "down"

	if player.x+28-room.relativex < self.x:
		self.x -= 2
		self.direction = "left"
	if player.x-28-room.relativex > self.x:
		self.direction = "right"
		self.x += 2	
	if player.y+10-room.relativey < self.y:
		self.direction = "up"
		self.y -= 2
	if player.y-10-room.relativey > self.y:
		self.direction = "down"
		self.y += 2

    def collide(self, room, player):
        # FIX BUG
        #print 'gameobject x=%d y=%d player x=%d y=%d' % (self.x,self.y,player.x-room.relativex,player.y-room.relativey)
	if (player.x-room.relativex > self.x-self.w  and 
	player.x-room.relativex < self.x+self.w+self.w and 
	player.y-room.relativey > self.y-self.h and 
	player.y-room.relativey < self.y + self.h +self.h):
	    #print "collision with Game Object!"
	    return 1 
	else:
	    return 0 ## for game self.talker


    def fight(self,room,player):
        self.fightcounter = 1
        o = player.collidewithenemyweapon(room,self)
        if o:
            player.hitwithenemyweapon(RNG().rollgoblinknife())

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from time import *
from venomspit import *

class Gohma(Gameobject):
    "Gohma enemy"
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 64
        self.h = 64 
	self.stimlibleft = Stateimagelibrary()	
	self.stimlibright = Stateimagelibrary()	
        image = pygame.image.load('./pics/gohma1.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/gohma1.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/gohma1.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/gohma1.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
        image = pygame.image.load('./pics/gohma2.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/gohma2.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/gohma2.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/gohma2.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
        image = pygame.image.load('./pics/gohma3.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/gohma3.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/gohma3.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/gohma3.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/gohma4.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/gohma4.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/gohma4.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/gohma4.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)

        image = pygame.image.load('./pics/gohma1.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/gohma1.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/gohma1.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/gohma1.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
        image = pygame.image.load('./pics/gohma2.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/gohma2.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/gohma2.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/gohma2.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
        image = pygame.image.load('./pics/gohma3.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/gohma3.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/gohma3.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/gohma3.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/gohma4.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/gohma4.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/gohma4.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/gohma4.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)

	self.direction = "left"

    def draw(self, screen, room):
	if (self.direction == "left"):
            self.stimlibleft.draw(screen, self.x+room.relativex,self.y+room.relativey)
	elif (self.direction == "right"):
            self.stimlibright.draw(screen, self.x+room.relativex,self.y+room.relativey)
	    
	     
    def update(self,room):
        sleep(.01) # FIX darkknight sleep
	if (random.randint(0,100) == 0 and self.direction == "left"):
	   self.direction = "right"
	elif (random.randint(0,100) == 0 and self.direction == "right"):
	   self.direction = "left"

	if (not self.collideobjectX(room)): 
	    if (self.direction == "left"):
	        self.x +=2
	        self.direction = "right" 
	    elif (self.direction == "right"):
	        self.x -=2
	        self.direction = "left"


	if (self.direction == "left"):
	        self.x -=1 
	elif (self.direction == "right"):
	        self.x +=1

        if random.randint(0,300) == 0:
            room.gameobjects.append(Venomspit(self.x+self.w/2,self.y+self.h))

    def collide(self, room, player):
	if (player.x > self.x+room.relativex  and 
	player.x < self.x+room.relativex+self.w and 
	player.y > self.y+room.relativey and 
	player.y < self.y+room.relativey + self.h):
	    print "collision with Gohma!"
	    if player.hit():
		return 1 
	    else:
	    	return 2 
	else:
	    return 0

		 

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from time import *
from venomspit import *

class GohmaRight(Gameobject):
    "Gohma enemy"
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 64
        self.h = 64 
	self.stimlibleft = Stateimagelibrary()	
	self.stimlibright = Stateimagelibrary()	
        image = pygame.image.load('./pics/gohmaright1.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/gohmaright1.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/gohmaright1.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/gohmaright1.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
        image = pygame.image.load('./pics/gohmaright2.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/gohmaright2.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/gohmaright2.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/gohmaright2.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
        image = pygame.image.load('./pics/gohmaright3.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/gohmaright3.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/gohmaright3.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/gohmaright3.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/gohmaright4.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/gohmaright4.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/gohmaright4.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/gohmaright4.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)

        image = pygame.image.load('./pics/gohmaright1.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/gohmaright1.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/gohmaright1.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/gohmaright1.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
        image = pygame.image.load('./pics/gohmaright2.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/gohmaright2.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/gohmaright2.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/gohmaright2.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
        image = pygame.image.load('./pics/gohmaright3.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/gohmaright3.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/gohmaright3.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/gohmaright3.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/gohmaright4.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/gohmaright4.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/gohmaright4.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/gohmaright4.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)

	self.direction = "down"

    def draw(self, screen, room):
	if (self.direction == "down"):
            self.stimlibleft.draw(screen, self.x+room.relativex,self.y+room.relativey)
	elif (self.direction == "up"):
            self.stimlibright.draw(screen, self.x+room.relativex,self.y+room.relativey)
	    
	     
    def update(self,room):
        sleep(.01) # FIX darkknight sleep
##	if (random.randint(0,100) == 0 and self.direction == "up"):
##	   self.direction = "down"
##	elif (random.randint(0,100) == 0 and self.direction == "down"):
##	   self.direction = "up"

	if (self.collideobjectXY(room)): 
	    if (self.direction == "up"):
	        self.y +=2
	        self.direction = "down" 
	    elif (self.direction == "down"):
	        self.y -=2
	        self.direction = "up"


	if (self.direction == "up"):
	        self.y -=1 
	elif (self.direction == "down"):
	        self.y +=1

        #FIX gohma down spit venom if random.randint(0,300) == 0:
        #    room.gameobjects.append(Venomspit(self.x+self.w/2,self.y+self.h))

    def collide(self, room, player):
	if (player.x > self.x+room.relativex  and 
	player.x < self.x+room.relativex+self.w and 
	player.y > self.y+room.relativey and 
	player.y < self.y+room.relativey + self.h):
	    print "collision with gohmadown!"
	    if player.hit():
		return 1 
	    else:
	    	return 2 
	else:
	    return 0

		 

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from time import *
from venomspitup import *

class GohmaUp(Gameobject):
    "Gohma Up"
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 64
        self.h = 64 
	self.stimlibleft = Stateimagelibrary()	
	self.stimlibright = Stateimagelibrary()	
        image = pygame.image.load('./pics/gohmaup1.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/gohmaup1.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/gohmaup1.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/gohmaup1.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
        image = pygame.image.load('./pics/gohmaup2.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/gohmaup2.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/gohmaup2.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/gohmaup2.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
        image = pygame.image.load('./pics/gohmaup3.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/gohmaup3.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/gohmaup3.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/gohmaup3.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/gohmaup4.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/gohmaup4.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/gohmaup4.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/gohmaup4.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)

        image = pygame.image.load('./pics/gohmaup1.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/gohmaup1.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/gohmaup1.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/gohmaup1.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
        image = pygame.image.load('./pics/gohmaup2.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/gohmaup2.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/gohmaup2.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/gohmaup2.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
        image = pygame.image.load('./pics/gohmaup3.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/gohmaup3.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/gohmaup3.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/gohmaup3.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/gohmaup4.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/gohmaup4.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/gohmaup4.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/gohmaup4.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)

	self.direction = "left"

    def draw(self, screen, room):
	if (self.direction == "left"):
            self.stimlibleft.draw(screen, self.x+room.relativex,self.y+room.relativey)
	elif (self.direction == "right"):
            self.stimlibright.draw(screen, self.x+room.relativex,self.y+room.relativey)
	    
	     
    def update(self,room):
        sleep(.01) # FIX gohma up sleep
	if (random.randint(0,100) == 0 and self.direction == "left"):
	   self.direction = "right"
	elif (random.randint(0,100) == 0 and self.direction == "right"):
	   self.direction = "left"

	if (not self.collideobjectX(room)): 
	    if (self.direction == "left"):
	        self.x +=2
	        self.direction = "right" 
	    elif (self.direction == "right"):
	        self.x -=2
	        self.direction = "left"


	if (self.direction == "left"):
	        self.x -=1 
	elif (self.direction == "right"):
	        self.x +=1

        if random.randint(0,300) == 0:
            room.gameobjects.append(VenomspitUp(self.x+self.w/2,self.y))

    def collide(self, room, player):
	if (player.x > self.x+room.relativex  and 
	player.x < self.x+room.relativex+self.w and 
	player.y > self.y+room.relativey and 
	player.y < self.y+room.relativey + self.h):
	    print "collision with Gohma up!"
	    if player.hit():
		return 1 
	    else:
	    	return 2 
	else:
	    return 0

		 

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from time import *

class HealingPotion(Gameobject):
    "Darknut"
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 36
        self.h = 50
	self.stimlib = Stateimagelibrary()		
        image = pygame.image.load('./pics/healingpotion1-24x24.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlib.addpicture(image)	
	self.hitpoints = 10000000000

    def draw(self, screen, room):
        self.stimlib.draw(screen, self.x+room.relativex,self.y+room.relativey)
	
	     
    def update(self,room,player):
	1

    def pickup(self, player):
        #if self.collidepickup(room, player):
        #room.removeobject(self)
        return 6 # FIX 1 is value for pickupid in Game class

    def collidepickup(self, room, player):
        #print 'keyx=%d keyy=%d playerx=%d playery=%d' % (self.x,self.y,player.x-room.relativex,player.y-room.relativey)
	if (player.x-room.relativex > self.x-self.w  and 
	player.x-room.relativex < self.x+self.w+self.w and
	player.y-room.relativey > self.y and 
	player.y-room.relativey < self.y+self.h):
	    return 3 
	else:
	    return 0  
    
    def collide(self, room, player):
	return 0

        

# Copyright (C) Johan Ceuppens 2010 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *

class InnDoor(Gameobject):
    "Inn Door"
    def __init__(self, xx,yy):
        Gameobject.__init__(self,xx,yy)
        self.image = pygame.image.load('./pics/inndoor1-75x100.bmp').convert()
        self.image.set_colorkey((0,0,0)) 

    def collide(self, room, player):
	if (player.x > self.x+room.relativex  and 
	player.x < self.x+room.relativex+self.w and 
	player.y > self.y+room.relativey and 
	player.y < self.y+room.relativey + self.h):
	    print "collision in door!"
	    room.removeobject(self)#NOTE door opens (disappears)
	else:
	    return 0

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from time import *

class InnGuardian2(Gameobject):
    "Inn Guardian 2, left to right"
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 48
        self.h = 48 
	self.stimlibleft = Stateimagelibrary()	
	self.stimlibright = Stateimagelibrary()	
        image = pygame.image.load('./pics/innguardian2.1-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/innguardian2.2-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/innguardian2.3-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)	

        image = pygame.image.load('./pics/innguardianright2.1-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/innguardianright2.2-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/innguardianright2.3-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)	

	self.direction = "left"

    def draw(self, screen, room):
	if (self.direction == "left"):
            self.stimlibleft.draw(screen, self.x+room.relativex,self.y+room.relativey)
	elif (self.direction == "right"):
            self.stimlibright.draw(screen, self.x+room.relativex,self.y+room.relativey)
	    
	     
    def update(self,room):
        sleep(.05) # FIX darkkngith sleep
	if (random.randint(0,100) == 0 and self.direction == "left"):
	   self.direction = "right"
	elif (random.randint(0,100) == 0 and self.direction == "right"):
	   self.direction = "left"

	if (not self.collideobjectX(room)): 
	    if (self.direction == "left"):
	        self.x +=2
	        self.direction = "right" 
	    elif (self.direction == "right"):
	        self.x -=2
	        self.direction = "left"


	if (self.direction == "left"):
	        self.x -=1 
	elif (self.direction == "right"):
	        self.x +=1

    def collide(self, room, player):
	if (player.x > self.x+room.relativex  and 
	player.x < self.x+room.relativex+self.w and 
	player.y > self.y+room.relativey and 
	player.y < self.y+room.relativey + self.h):
	    print "collision with Inn Guardian 2!"
	    return 2 
	else:
	    return 0

    def talk(self, screen,font):
        if self.talkcounter == 0:
            return
        
        if self.talkcounter > 4:
                self.talkcounter = 0
                return 
        talkover = 0
        while talkover == 0:
            pygame.display.update()
            if self.talkcounter == 1:
                screen.blit(font.render("This is the Friendly Arm Inn.", 6, (255,255,255)), (10,100))
            elif self.talkcounter == 2:
                screen.blit(font.render("I am a guardian of the inn.", 6, (255,255,255)), (10,100))
            elif self.talkcounter == 3:
                screen.blit(font.render("The Innkeeper is named Yuan.", 6, (255,255,255)), (10,100))
            elif self.talkcounter == 4:
                screen.blit(font.render("Back in the day, he was a good warrior.", 6, (255,255,255)), (10,100))
            for event in pygame.event.get():
                if event.type == QUIT:
                    return
                elif event.type == KEYDOWN:
                    if event.key == K_z:
                        talkover = 1
                        self.talkcounter += 1
                	 

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from time import *
from innguardian2 import *

class InnGuardian3(InnGuardian2):
    "Inn Guardian 2, left to right"
    def __init__(self,xx,yy):
	InnGuardian2.__init__(self, xx, yy)
   
    def collide(self, room, player):
	if (player.x > self.x+room.relativex  and 
	player.x < self.x+room.relativex+self.w and 
	player.y > self.y+room.relativey and 
	player.y < self.y+room.relativey + self.h):
	    print "collision with Inn Guardian 3!"
	    return 2 
	else:
	    return 0

    def talk(self, screen,font):
        if self.talkcounter == 0:
            return
        
        if self.talkcounter > 3:
                self.talkcounter = 0
                return 
        talkover = 0
        while talkover == 0:
            pygame.display.update()
            if self.talkcounter == 1:
                screen.blit(font.render("This is the adventurer's hall.", 6, (255,255,255)), (10,100))
            elif self.talkcounter == 2:
                screen.blit(font.render("The guardians are all veteran warriors.", 6, (255,255,255)), (10,100))
            elif self.talkcounter == 3:
                screen.blit(font.render("We fought the Ratlins together with master Yuan.", 6, (255,255,255)), (10,100))
            for event in pygame.event.get():
                if event.type == QUIT:
                    return
                elif event.type == KEYDOWN:
                    if event.key == K_z:
                        talkover = 1
                        self.talkcounter += 1
                	 

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from time import *

class InnGuardian(Gameobject):
    ""
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 48
        self.h = 48	
        self.image = pygame.image.load('./pics/innguardian1-48x48.bmp').convert()
        self.image.set_colorkey((0,0,255)) 
        self.talkcounter = 0
        
    def draw(self, screen, room):
        screen.blit(self.image, (self.x+room.relativex,self.y+room.relativey))
	    
	     
    def update(self,room):
        1

    def collide(self, room, player):
	if (player.x > self.x+room.relativex  and 
	player.x < self.x+room.relativex+self.w and 
	player.y > self.y+room.relativey and 
	player.y < self.y+room.relativey + self.h):
	    print "collision with Inn Guardian!"
	    return 2 
	else:
	    return 0
		 
    def talk(self, screen,font):
        if self.talkcounter == 0:
            return
        
        if self.talkcounter > 2:
                self.talkcounter = 0
                return 
        talkover = 0
        while talkover == 0:
            pygame.display.update()
            if self.talkcounter == 1:
                screen.blit(font.render("This is the Friendly Arm Inn.", 6, (255,255,255)), (10,100))
            elif self.talkcounter == 2:
                screen.blit(font.render("You may enter if you want.", 6, (255,255,255)), (10,100))
            for event in pygame.event.get():
                if event.type == QUIT:
                    return
                elif event.type == KEYDOWN:
                    if event.key == K_z:
                        talkover = 1
                        self.talkcounter += 1
                

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import pygame
from pygame.locals import *

from inventoryitem import *

class Inventorybomb(Inventoryitem):
    def __init__(self):
        Inventoryitem.__init__(self, "./pics/bomb1.bmp")

    def use(self,e,game):
        print 'You used a bomb on %s' % e

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import pygame
from pygame.locals import *

from inventoryitem import *

class Inventorybow1(Inventoryitem):
    def __init__(self):
        Inventoryitem.__init__(self, "./pics/bow1-36x36.bmp")
        self.image.set_colorkey((0,0,255))
        
    def use(self,e,game):
        print 'You used a bow on %s' % e

    def setintaskbar(self,taskbar):
        taskbar.setbow()

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import pygame
from pygame.locals import *


class Inventoryitem(object):
    def __init__(self,imagefilename):
        self.image = pygame.image.load(imagefilename).convert()
        self.image.set_colorkey((0,0,0))#FIXME rgb transdparency
	self.id = None

    def draw(self,screen,x,y):
        screen.blit(self.image, (x, y))

    def addtolist(self,list):
        list.addobject(self)

    def setintaskbar(self,taskbar):
        1
#NOTE There s no fallthrough for item usage

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import pygame
from pygame.locals import *

from inventoryitem import *

class Inventorykey1(Inventoryitem):
    def __init__(self):
        Inventoryitem.__init__(self, "./pics/dungeonkey1-36x36.bmp")

    def use(self,e,game):
        print 'You used Key 1 on %s' % e

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import pygame
from pygame.locals import *

from inventoryitem import *

class Inventoryknife1(Inventoryitem):
    def __init__(self):
        Inventoryitem.__init__(self, "./pics/sword1-36x36.bmp")
        self.image.set_colorkey((0,0,255))
        
    def use(self,e,game):
        print 'You used a Knife1 on %s' % e

    def setintaskbar(self,taskbar):
        taskbar.setsword1()

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import pygame
from pygame.locals import *

from inventoryitem import *

class Inventorylongbow1(Inventoryitem):
    def __init__(self):
        Inventoryitem.__init__(self, "./pics/longbow1-36x36.bmp")
        self.image.set_colorkey((0,0,255))
        
    def use(self,e,game):
        print 'You used a Lonbow on %s' % e

    def setintaskbar(self,taskbar):
        taskbar.setlongbow()

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import pygame
from pygame.locals import *

from inventoryitem import *

class Inventorymasterkey(Inventoryitem):
    def __init__(self):
        Inventoryitem.__init__(self, "./pics/dungeonmasterkey1-36x36.bmp")

    def use(self,e,game):
        print 'You used a Master Key on %s' % e

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from inventorybomb import *

class Inventory(object):
    def __init__(self):
        self.background = pygame.image.load('./pics/blank.bmp').convert()
        self.list = []
	self.ITEMWIDTH = 36 
	self.ITEMMAX = 7 
        #self.list.append(Inventorybomb())

        self.rectimage = pygame.image.load('./pics/rectinventory-36x36.bmp').convert()
        self.rectimage.set_colorkey((0,0,0))
        self.selectioncounter = 0 

    def draw(self,screen):

        screen.blit(self.background, (0, 0))

        for i in range(0,len(self.list)):
            o = self.list[i]
            if o:
                o.draw(screen,40*(i%self.ITEMMAX),i/36)

	x = self.selectioncounter * self.ITEMWIDTH % self.ITEMMAX*self.ITEMWIDTH 
	y = self.selectioncounter / self.ITEMMAX * self.ITEMWIDTH
        self.drawrect(screen,x,y)

    def drawrect(self,screen,x,y):
        screen.blit(self.rectimage, (x, y))


    def moveleft(self):
        if self.selectioncounter > 0:
            self.selectioncounter -= 1

    def moveright(self):
        if self.selectioncounter < self.ITEMMAX * self.ITEMMAX:
            self.selectioncounter += 1

#    def setselection(self):
#        i = 
        
    def getitem(self,o):
#        for i in range(0,self.selectioncounter):
#            o = None
#            o = self.list.getlistobject(o)
	if len(self.list) > self.selectioncounter:
        	o = self.list[self.selectioncounter]
        	if o:
            		return o

        return None

    def additem(self,o):
        self.list.append(o)

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import pygame
from pygame.locals import *

from inventoryitem import *

class Inventoryscrollinvisibility(Inventoryitem):
    def __init__(self):
        Inventoryitem.__init__(self, "./pics/scroll1.bmp")

    def use(self,e,game):
        print 'You used a scroll of invisibility on %s' % e
        if e:
            return e.usescrollinvisibility(game)
	

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import pygame
from pygame.locals import *

from inventoryitem import *

class Inventorysword1(Inventoryitem):
    def __init__(self):
        Inventoryitem.__init__(self, "./pics/sword1-36x36.bmp")
        self.image.set_colorkey((0,0,255))
        
    def use(self,e,game):
        print 'You used a Sword1 on %s' % e

    def setintaskbar(self,taskbar):
        taskbar.setsword1()

# Copyright (C) Johan Ceuppens 2010 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from rng import *

class Knife(Gameobject):
    "Box"
    def __init__(self, xx,yy,ox,oy,player):
        Gameobject.__init__(self,xx,yy)
        self.ox = ox
        self.oy = oy
        self.hitpoints = 1000000000 #FIX else wall/floor disappears
        #FIX is in base class self.image = pygame.image.load('./pics/.bmp').convert()
        #self.image.set_colorkey((0,0,0)) 
        self.image = pygame.image.load('./pics/knife1-16x16.bmp').convert()
        self.image.set_colorkey((0,0,255)) 
        self.image2 = pygame.image.load('./pics/knifeleft1-16x16.bmp').convert()
        self.image2.set_colorkey((0,0,255)) 

	self.player = player


    def draw(self, screen, room):
        if self.player.x+room.relativex < self.ox:
		screen.blit(self.image,(self.x-room.relativex,self.y-room.relativey))
        else:
		screen.blit(self.image2,(self.x-room.relativex,self.y-room.relativey))

    def update(self,room,player):
	if player.x+room.relativex < self.ox:
		self.x += 15
	elif player.x+room.relativex > self.ox:
		self.x -= 15
		
	if abs(self.x-self.ox) < 20:
		room.removeobject(self)

    def pickup(self, room):
        room.removeobject(self)
	return 55#FIX

    def collide(self, room, player):
        ###print 'gameobject x=%d y=%d player x=%d y=%d' % (self.x,self.y,player.x-room.relativex,player.y-room.relativey)
	return 55#FIX
    

    def roll(self):
	return RNG().rollknife()

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from time import *

class Knight2(Gameobject):
    ""
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 64
        self.h = 64 
	self.stimlib = Stateimagelibrary()
        image = pygame.image.load('./pics/knight2front1-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
        image = pygame.image.load('./pics/knight2front2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
        image = pygame.image.load('./pics/knight2front3-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/knight2front2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)

        self.staticimage = pygame.image.load('./pics/knight2front1-36x36.bmp').convert()
        self.staticimage.set_colorkey((0,0,0)) 
	
	self.direction = "down"
        self.talkcounter = 0

    def draw(self, screen, room):
	if (self.direction == "down"):
            self.stimlib.draw(screen, self.x+room.relativex,self.y+room.relativey)
	else:
            screen.blit(self.staticimage,(self.x+room.relativex,self.y+room.relativey))
             
    def update(self,room):
        sleep(.2)
	if (self.direction == "down"):
                if self.y > 180:
                    self.direction = "stop"
	        self.y +=2 
	else:
	        self.y +=0

    def collide(self, room, player):
	if (player.x > self.x+room.relativex  and 
	player.x < self.x+room.relativex+self.w and 
	player.y > self.y+room.relativey and 
	player.y < self.y+room.relativey + self.h):
	    print "collision with Knight2!"
            return 2 
	else:
	    return 0


    def talk(self, screen, font):
       if self.talkcounter == 0:
            return
        
       if self.talkcounter > 2:
                self.talkcounter = 0
                return 
       talkover = 0
       while talkover == 0:
            pygame.display.update()
            if self.talkcounter == 1:
                screen.blit(font.render("Watch out for Gohma", 8, (255,255,255)), (100,100))
            elif self.talkcounter == 2:
                screen.blit(font.render("He spits venom.", 8, (255,255,255)), (100,100))
            for event in pygame.event.get():
                if event.type == QUIT:
                    return
                elif event.type == KEYDOWN:
                    if event.key == K_z:
                        talkover = 1
                        self.talkcounter += 1
                


		 

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from time import *
from rng import *

class KnightFighting(Gameobject):
    "Enemy Knight"
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 48
        self.h = 64

        self.hitpoints = 14

        self.swordimage = pygame.image.load('./pics/sword1-36x36.bmp').convert()
        self.swordimage.set_colorkey((0,0,255)) 
	
        self.swordimage2 = pygame.image.load('./pics/swordleft1-36x36.bmp').convert()
        self.swordimage2.set_colorkey((0,0,255)) 
	
	self.stimlibleft = Stateimagelibrary()	
	self.stimlibright = Stateimagelibrary()	
        image = pygame.image.load('./pics/knightfightingleft1-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/knightfightingleft1-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/knightfightingleft1-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/knightfightingleft1-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/knightfightingleft1-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
        image = pygame.image.load('./pics/knightfightingleft2-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/knightfightingleft2-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/knightfightingleft2-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/knightfightingleft2-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/knightfightingleft2-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/knightfightingleft3-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/knightfightingleft3-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/knightfightingleft3-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/knightfightingleft3-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/knightfightingleft3-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
        image = pygame.image.load('./pics/knightfightingleft4-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/knightfightingleft4-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/knightfightingleft4-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/knightfightingleft4-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/knightfightingleft4-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
        image = pygame.image.load('./pics/knightfightingleft3-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/knightfightingleft3-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/knightfightingleft3-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/knightfightingleft3-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/knightfightingleft3-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
        image = pygame.image.load('./pics/knightfightingleft2-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/knightfightingleft2-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/knightfightingleft2-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/knightfightingleft2-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/knightfightingleft2-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)



	
	image = pygame.image.load('./pics/knightfightingright1-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/knightfightingright1-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/knightfightingright1-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/knightfightingright1-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/knightfightingright1-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
        image = pygame.image.load('./pics/knightfightingright2-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/knightfightingright2-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/knightfightingright2-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/knightfightingright2-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/knightfightingright2-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
        image = pygame.image.load('./pics/knightfightingright3-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/knightfightingright3-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/knightfightingright3-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/knightfightingright3-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/knightfightingright3-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
        image = pygame.image.load('./pics/knightfightingright4-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/knightfightingright4-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/knightfightingright4-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/knightfightingright4-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/knightfightingright4-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
        image = pygame.image.load('./pics/knightfightingright3-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/knightfightingright3-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/knightfightingright3-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/knightfightingright3-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/knightfightingright3-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
        image = pygame.image.load('./pics/knightfightingright2-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/knightfightingright2-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/knightfightingright2-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/knightfightingright2-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/knightfightingright2-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)

	
        self.stimlibleftfight = Stateimagelibrary()	
	self.stimlibrightfight = Stateimagelibrary()	
	image = pygame.image.load('./pics/knightfightingright1-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibrightfight.addpicture(image)
	image = pygame.image.load('./pics/knightfightingleft1-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleftfight.addpicture(image)

	self.stimlibleftfightlow = Stateimagelibrary()	
	self.stimlibrightfightlow = Stateimagelibrary()	
	image = pygame.image.load('./pics/knightfightingright2-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibrightfightlow.addpicture(image)
	image = pygame.image.load('./pics/knightfightingleft2-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleftfightlow.addpicture(image)

        self.battlemode = 1

	self.direction = "left"
        self.prevdirection = "left"

        self.CLOSEUPW = 58
        self.counter = 0

    def draw(self, screen, room):
        #FIXME - or + room.relativex
	if (self.direction == "left"):
            self.stimlibleft.draw(screen, self.x+room.relativex,self.y+room.relativey)
	elif (self.direction == "right"):
            self.stimlibright.draw(screen, self.x+room.relativex,self.y+room.relativey)

        elif self.direction == "stop":
            if self.player.x-room.relativex < self.x:
                self.stimlibleftfight.drawstatic(screen, self.x+room.relativex,self.y+room.relativey,0)
                screen.blit(self.swordimage2,(self.x+room.relativex-self.w+5,self.y+room.relativey))
            if self.player.x-room.relativex > self.x:
                self.stimlibrightfight.drawstatic(screen, self.x+room.relativex,self.y+room.relativey,0)
                screen.blit(self.swordimage,(self.x+room.relativex+self.w+5,self.y+room.relativey))
            
    def update(self,room,player):
        self.player = player
        # combat for knight i.e. move in and fight like a knight
        if player.x-room.relativex < self.x:
            self.direction = "left"
            self.prevdirection = "left"
        elif player.x-room.relativex > self.x:
            self.direction = "right"
            self.prevdirection = "right"

        if abs(player.x-room.relativex - self.x) < self.CLOSEUPW:
            if self.direction != "stop":
                self.direction = "stop"
            elif self.direction == "stop" and self.counter <= 0:
                r = randint(1,2)
                if r == 1:
                    self.direction = "left"
                else:
                    self.direction = "right"

##	if (not self.collideobjectX(room)): 
##	    if (self.direction == "left"):
##	        self.x +=2
##	        self.direction = "right" 
##	    elif (self.direction == "right"):
##	        self.x -=2
##	        self.direction = "left"
##	        
        if (self.direction == "stop"):
            #FIXME          
            #self.fight(room,player,0)
            if randint(0,10) == 0:
                player.hitwithenemyweapon(RNG().rollknight())
                self.counter = 10

	if (self.direction == "left"):
	        self.x -=1 
	elif (self.direction == "right"):
	        self.x +=1

    def collide(self, room, player):        
	if (player.x > self.x-room.relativex-self.w  and 
	player.x < self.x-room.relativex+self.w+self.w and 
	player.y > self.y-room.relativey-self.h and 
	player.y < self.y-room.relativey + self.h +self.h):
	    print "collision with Knight!"
	    if player.hit():
		return 1 
	    else:
	    	return 2 
	else:
	    return 0

		 
    def collidewithsword(self, room, player):
        print 'knight x=%d y=%d player x=%d y=%d' % (self.x,self.y,player.x-room.relativex,player.y-room.relativey)
	if (player.x-room.relativex > self.x  and 
	player.x-room.relativex < self.x+self.w and 
	player.y-room.relativey > self.y and 
	player.y-room.relativey < self.y + self.h):
	    print "collision with Sword knight!"
	    return 1 
	else:
	    return 0


    def fight(self,room,player):
        self.fightcounter = 1
        # FIXME FIGHT!
        
        o = player.collidewithenemyweapon(room,self)
        
        if o:
            # FIXME roll
            player.hitwithenemyweapon(RNG().rollknight())

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from time import *

class Knight(Gameobject):
    ""
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 64
        self.h = 64 
	self.stimlibleft = Stateimagelibrary()	
	self.stimlibright = Stateimagelibrary()	
        image = pygame.image.load('./pics/knightdarkleft1-30x30.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
        image = pygame.image.load('./pics/knightdarkleft2-30x30.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
        image = pygame.image.load('./pics/knightdarkleft3-30x30.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/knightdarkright1-30x30.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
        image = pygame.image.load('./pics/knightdarkright2-30x30.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
        image = pygame.image.load('./pics/knightdarkright3-30x30.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
	self.direction = "left"

    def draw(self, screen, room):
	if (self.direction == "left"):
            self.stimlibleft.draw(screen, self.x+room.relativex,self.y+room.relativey)
	elif (self.direction == "right"):
            self.stimlibright.draw(screen, self.x+room.relativex,self.y+room.relativey)
	    
	     
    def update(self,room):
        sleep(.01)
##        self.x-=1
##	if (random.randint(0,100) == 0 and self.direction == "left"):
##	   self.direction = "right"
##	elif (random.randint(0,100) == 0 and self.direction == "right"):
##	   self.direction = "left"
##
	if (not self.collideobjectX(room)): 
	    if (self.direction == "left"):
	        self.x +=2
	        self.direction = "right" 
	    elif (self.direction == "right"):
	        self.x -=2
	        self.direction = "left"


	if (self.direction == "left"):
	        self.x -=1 
	elif (self.direction == "right"):
	        self.x +=1

    def collide(self, room, player):
	if (player.x > self.x+room.relativex  and 
	player.x < self.x+room.relativex+self.w and 
	player.y > self.y+room.relativey and 
	player.y < self.y+room.relativey + self.h):
	    print "collision with Knight!"
	    if player.hit():
		return 1 
	    else:
	    	return 2 
	else:
	    return 0
		 

# Copyright (C) Johan Ceuppens 2010 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *

class Knightstatue1(Gameobject):
    ""
    def __init__(self, xx,yy):
        Gameobject.__init__(self,xx,yy)
        self.w = 48 
        self.h = 48 
        self.image = pygame.image.load('./pics/dungeon-knightstatue1-48x48.bmp').convert()
        self.image.set_colorkey((0,0,0)) 

    def collide(self, room, player):
	return 0


# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random

class KoboldWizard(Gameobject):
    ""
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 50
        self.h = 50 
	self.stimlibleft = Stateimagelibrary()	
	self.stimlibright = Stateimagelibrary()	
        image = pygame.image.load('./pics/koboldwizard-50x50.bmp').convert()
        image.set_colorkey((255,255,255)) 
	self.stimlibleft.addpicture(image)
        self.talkcounter = 0

    def draw(self, screen, room):
        self.stimlibleft.draw(screen, self.x+room.relativex,self.y+room.relativey)    
	     
    def update(self,room):
        1

    def collide(self, room, player):
	if (player.x > self.x+room.relativex  and 
	player.x < self.x+room.relativex+self.w and 
	player.y > self.y+room.relativey and 
            player.y < self.y+room.relativey + self.h):
            #print "collision with Kobold Wizard!"
            return 2 ## NOTE 2 for talker
	else:
	    return 0

    def talk(self, screen):
        self.talkcounter += 1
        if self.talkcounter > 2:
                self.talkcounter = 0
        if self.talkcounter == 0:
            return
        if self.talkcounter == 1:
            screen.blit(self.font.render("Watch out for Gohma. He spits venom!", 8, (255,255,255)), (100,100))
        elif self.talkcounter == 2:
            screen.blit(self.font.render("Ask the alchemist for poison.", 8, (255,255,255)), (100,100))
        for event in pygame.event.get():
                if event.type == QUIT:
                    return
                elif event.type == KEYDOWN:
            	    if event.key == K_z:
                        return
       
##        screen.blit(font.render("Watch out for Gohma. He spits venom!",4, (255,255,255)), (10,100))
##        pygame.display.update()
##        sleep(1)
##        for event in pygame.event.get():
##            self.room.draw(screen) 
##           
##            pygame.display.update()
##            if event.type == QUIT:
##                return
##            elif event.type == KEYDOWN:
##                if event.key == K_z:
##                  break

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from time import *
from rng import *

class Longbow1(Gameobject):
    ""
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 50
        self.h = 50
	self.stimlib = Stateimagelibrary()		
        image = pygame.image.load('./pics/longbow1-36x36.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlib.addpicture(image)	
	self.hitpoints = 1000000000
	self.id = "longbow"

    def draw(self, screen, room):
        self.stimlib.draw(screen, self.x+room.relativex,self.y+room.relativey)
	
    def update(self,room,player):
	1

    def pickup(self, player):
        #if self.collidepickup(room, player):
        #room.removeobject(self)
        return 8 # FIX 1 is value for pickupid in Game class

    def collidepickup(self, room, player):
        #print 'keyx=%d keyy=%d playerx=%d playery=%d' % (self.x,self.y,player.x-room.relativex,player.y-room.relativey)
	if (player.x-room.relativex > self.x-self.w  and 
	player.x-room.relativex < self.x+self.w+self.w and
	player.y-room.relativey > self.y and 
	player.y-room.relativey < self.y+self.h):
	    return 3 
	else:
	    return 0 
    
    def collide(self, room, player):
	return 0

    def roll(self):
	return RNG().rolllongbow()

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from maproom import *
from knight import *
from mongbat import *
from maproom2 import *
from dungeonkey2 import *
from gohma import *
from gohmaup import *

class Maproom10(Maproom):
    "Room with a (big) map"
    def __init__(self,x,y):
        Maproom.__init__(self,x,y)
        self.background = pygame.image.load('./pics/room-bg10.bmp').convert()	#self.gameobjects.append(Dungeonmasterkey(50,50))
	self.gameobjects.append(Dungeonwall(0,0,300,40))
	self.gameobjects.append(Dungeonwall(0,260,300,40))
	self.gameobjects.append(Dungeonwall(0,0,40,300))
	self.gameobjects.append(Gohma(0,20))
	self.gameobjects.append(GohmaUp(0,200))
	if not self.dungeonkey2:
            self.gameobjects.append(Dungeonkey2GohmaLair(130,130))
##	self.gameobjects.append(Dungeonwall(260,0,40,300))
##	self.gameobjects.append(Mongbat(100,50))
##	self.gameobjects.append(Mongbat(200,100))
##	self.gameobjects.append(Mongbat(100,150))
##	self.gameobjects.append(Mongbat(200,200))


    def draw(self,screen):
        screen.blit(self.background, (0+self.relativex, 0+self.relativey))
        for i in self.gameobjects:
	    if i:
                i.draw(screen,self)
 
    def collide(self, player):
	for i in self.gameobjects:
	    if i != None:
		i.update(self)	
	for i in self.gameobjects:
            if i != None:
                id = i.collide(self,player)
                self.relativex = self.prevx
		self.relativey = self.prevy
		return id
	return 0

    def pickup(self, player):###FIX for each room
        for o in self.gameobjects:
            if (o and o.collide(self, player)):##FIX o.colidepickup
                id = o.pickup(self)
                self.dungeonkey2 = 1
		return id
        return 0
    
    def exit(self, game):
        if self.isroomdownexit():
	    self.setxyfromdown()	
	    return 9
	else:
	    return 0

    def removeobject(self, o):
        for i in (0,len(self.gameobjects)-1):
            if (self.gameobjects[i] and self.gameobjects[i] == o):
                print "PICKUP"
                self.gameobjects[i] = None

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from maproom import *
from tree import *
from tree2 import *
from dungeonentrance1 import *
from maproom2 import *
from goblin1 import *
from box import *

class Maproom1_1_1(Maproom):
    "Room with a (big) map - west of knight's castle"
    def __init__(self,x,y):
        Maproom.__init__(self,x,y)
        self.background = pygame.image.load('./pics/room-bg1_1_1.bmp').convert()
        #FIX	self.gameobjects.append(Dungeonentrance1(0,0))
	self.gameobjects.append(Tree2(10,100))
	self.gameobjects.append(Tree2(100,100))
	self.gameobjects.append(Tree2(200,120))
        self.gameobjects.append(Goblin1(50,230))
        self.gameobjects.append(Goblin1(440,230))
        b = Box(650,0,150,300)
        b.setimage('./pics/knightdungeon1-150x350.bmp',0,0,0)
        self.gameobjects.append(b)
        # upper crevasses
        self.gameobjects.append(Box(0,0,375,75))
        self.gameobjects.append(Box(375,0,100,100))
        self.gameobjects.append(Box(475,0,100,125))
        self.gameobjects.append(Box(500,0,120,180))
        self.gameobjects.append(Box(600,0,50,160))
        self.gameobjects.append(Box(650,0,25,75))
        self.gameobjects.append(Box(675,0,75,40))
        self.gameobjects.append(Box(750,0,50,40))
        # lower crevasses
        self.gameobjects.append(Box(500,220,120,400))
        self.gameobjects.append(Box(0,400,800,100))

 
    def draw(self,screen):
        screen.blit(self.background, (0+self.relativex, 0+self.relativey))
        for i in self.gameobjects:
	    if i != None:
		i.draw(screen,self)

    def collide(self, player):
	for i in self.gameobjects:
	    if i != None: 
		i.update(self)	
	for i in self.gameobjects:
	    if i != None and i.collide(self, player):
		self.relativex = self.prevx
		self.relativey = self.prevy
		return  

    def isroomdownexit(self):
	if self.relativex  < -140 and self.relativex > -200 and self.relativey < -210:### and self.relativey < 20:
		return 1
	return 0

    def setxyfromdown(self):
        self.relativex = 0
	self.relativey = 0

    def isroomleftexit(self):
	if self.relativex  > 100:
		return 1
	return 0

    def setxyfromleft(self):
        self.relativex = 0
	self.relativey = 0
	

    def exit(self, game):
        # To Mithran and Gohma's Lair and Lady of the Lake Knight Chateau
        print 'x=%d y=%d' % (self.relativex,self.relativey)
	if self.relativey < -50 and self.relativex < -580:
	    game.setxy(0,-80)	
	    return 2#FIX
        # To south 
	elif self.isroomdownexit():
            self.setxyfromdown()
            return 1.1#FIX
        # To the west
        elif self.isroomleftexit():
            self.setxyfromleft()
            return 1.1#FIX
	else:
	    return 0 
 
    def collidesword(self,room,player):
        for i in self.gameobjects:
	    if i!= None:
	    	c = i.collide(room,player)
		if c == 1:
			return i ## NOTE : returns collided entity (single)
		self.relativex = self.prevx
		self.relativey = self.prevy
	return None

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from maproom import *
from knight import *
from blackknight import *
from demon import *
from bombman import *
from turtleflying import *
from ghost1 import *
from ghostwandering import *
from ghostcircling import *
from maproom2 import *
from dungeonmasterkey import *
from dungeonkey1 import *
from mithran import *

class Maproom1_1(Maproom):
    "Room with a (big) map - South of Knight's Castle, Towards Grove"
    def __init__(self,x,y):
        Maproom.__init__(self,x,y)
        self.background = pygame.image.load('./pics/room-bg1_1.bmp').convert()

        #FIX1 archmage Mithran
        self.mithran = Mithran(110,120)
	self.gameobjects.append(self.mithran)
	# walls towards grove
	self.gameobjects.append(Dungeonwall(0,0,100,500))
	self.gameobjects.append(Dungeonwall(200,0,100,500))
	     
    def draw(self,screen):
        screen.blit(self.background, (0+self.relativex, 0+self.relativey))
        for i in self.gameobjects:
	    if i:
                i.draw(screen,self)
 
    def collide(self, player):
	for i in self.gameobjects:
	    if i != None:
		i.update(self)	
	for i in self.gameobjects:
	    if i!= None:
	    	id = i.collide(self,player)
		self.relativex = self.prevx
		self.relativey = self.prevy
		return id
	return 0

    def pickup(self, player):###FIX for each room
        for o in self.gameobjects:
            if (o and o.collide(self, player)):##FIX o.colidepickup
                id = o.pickup(self)
                self.dungeonkey1 = 1
		return id
        return 0
    
    def exit(self, game):
        # FIX
	return 0

    def removeobject(self, o):
        for i in (0,len(self.gameobjects)-1):
            print "o=%s self.gameobjects[i]=%s i=%d" % (o,self.gameobjects[i],i)
            if self.gameobjects[i] == o:
                print "PICKUP or die"
                self.gameobjects[i] = None
		return 

    def collidesword(self,room,player):
        for i in self.gameobjects:
	    if i!= None:
	    	c = i.collide(room,player)
	    	print "i=%s" % i
		if c == 1:
                        print "collision with i=%s!" % i
			return i ## NOTE : returns collided entity (single)
		self.relativex = self.prevx
		self.relativey = self.prevy
	return None

    def isroomdownexit(self):
	if self.relativey < - 320:### and self.relativey < 20:
		return 1
	return 0

    def setxyfromdown(self):
        self.relativex = 0
	self.relativey = 0

    def setxyfromup(self):#FIXME
        self.relativex = -200
	self.relativey = -200
	
	
    def exit(self, game):
        print "x=%d y=%d" % (self.relativex,self.relativey)
        if self.isroomupexit():
	    self.setxyfromup()	    
	    return 1
	elif self.isroomdownexit():
	    self.setxyfromdown()	    
	    return 1.2
	#Trap door: elif self.isroomdownexit():
	#    self.setxyfromdown()	
	#    return 11
	else:
	    return 0


    def talkto(self):#FIXME needs font
            print "talk to in maproom 6"
            ## return self.koboldwiz
            self.mithran.talkcounter = 1 # FIXME public var
            return self.mithran

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from maproom import *
from knight import *
from mongbat import *
from maproom2 import *
from dungeonmasterkey import *
from gohma import *
from gohmaup import *
from box import *

class Maproom11(Maproom):
    "Room with a (big) map"
    def __init__(self,x,y):
        Maproom.__init__(self,x,y)
        self.background = pygame.image.load('./pics/room-bg11.bmp').convert()
        #self.gameobjects.append(Dungeonmasterkey(50,50))
        self.gameobjects.append(Dungeonwall(260,0,40,300))
	self.gameobjects.append(Dungeonwall(0,0,300,40))
	self.gameobjects.append(Dungeonwall(0,260,300,40))
	self.gameobjects.append(Dungeonwall(0,0,40,300))
	b = Box(85,85,140,25)
	b.setimage('./pics/nopicture.bmp',0,0,255)
	self.gameobjects.append(b)
	b = Box(200,85,25,115)
	b.setimage('./pics/nopicture.bmp',0,0,255)
	self.gameobjects.append(b)
	b = Box(85,200,115,25)
	b.setimage('./pics/nopicture.bmp',0,0,255)
	self.gameobjects.append(b)
	b = Box(85,85,25,115)
	b.setimage('./pics/nopicture.bmp',0,0,255)
	self.gameobjects.append(b)
##	self.gameobjects.append(Gohma(0,20))
##	self.gameobjects.append(GohmaUp(0,200))
##	self.gameobjects.append(Dungeonwall(260,0,40,300))
##	self.gameobjects.append(Mongbat(100,50))
##	self.gameobjects.append(Mongbat(200,100))
##	self.gameobjects.append(Mongbat(100,150))
##	self.gameobjects.append(Mongbat(200,200))


    def draw(self,screen):
        screen.blit(self.background, (0+self.relativex, 0+self.relativey))
        for i in self.gameobjects:
	    if i:
                i.draw(screen,self)
 
    def collide(self, player):
	for i in self.gameobjects:
	    if i != None:
		i.update(self)	
	for i in self.gameobjects:
            if i != None:
                id = i.collide(self,player)
                self.relativex = self.prevx
		self.relativey = self.prevy
		return id
	return 0

##    def pickup(self, player):
##        for o in self.gameobjects:
##            if (o and o.collidepickup(self, player)):
##                o.pickup(self)
##                return
##
    
    def exit(self, game):
        if self.isroomupexit():
	    self.setxyfromup()
	    self.y = -660 # NOTE
	    return 12
	elif self.isroomdownexit():
	    self.setxyfromdown()	
	    return 8
	else:
	    return 0

    def removeobject(self, o):
        for i in (0,len(self.gameobjects)-1):
            if (self.gameobjects[i] and self.gameobjects[i] == o):
                print "PICKUP"
                self.gameobjects[i] = None

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from maproom import *
from knight import *
from blackknight import *
from demon import *
from bombman import *
from turtleflying import *
from ghost1 import *
from ghostwandering import *
from ghostcircling import *
from maproom2 import *
from dungeonmasterkey import *
from dungeonkey1 import *
from mithran import *

class Maproom1_2(Maproom):
    "Room with a (big) map - Towards second south of Knight's Castle"
    def __init__(self,x,y):
        Maproom.__init__(self,x,y)
        self.background = pygame.image.load('./pics/room-bg1_2.bmp').convert()
	self.gameobjects.append(Dungeonwall(0,0,300,100))
	self.gameobjects.append(Dungeonwall(200,0,100,300))
	self.gameobjects.append(Dungeonwall(0,0,100,300))
	self.gameobjects.append(Dungeonwall(0,200,300,100))
	     
    def draw(self,screen):
        screen.blit(self.background, (0+self.relativex, 0+self.relativey))
        for i in self.gameobjects:
	    if i:
                i.draw(screen,self)
 
    def collide(self, player):
	for i in self.gameobjects:
	    if i != None:
		i.update(self)	
	for i in self.gameobjects:
	    if i!= None:
	    	id = i.collide(self,player)
		self.relativex = self.prevx
		self.relativey = self.prevy
		return id
	return 0

    def pickup(self, player):###FIX for each room
        for o in self.gameobjects:
            if (o and o.collide(self, player)):##FIX o.colidepickup
                id = o.pickup(self)
                self.dungeonkey1 = 1
		return id
        return 0
    
    def exit(self, game):
        # FIX
	return 0

    def removeobject(self, o):
        for i in (0,len(self.gameobjects)-1):
            print "o=%s self.gameobjects[i]=%s i=%d" % (o,self.gameobjects[i],i)
            if self.gameobjects[i] == o:
                print "PICKUP or die"
                self.gameobjects[i] = None
		return 

    def collidesword(self,room,player):
        for i in self.gameobjects:
	    if i!= None:
	    	c = i.collide(room,player)
	    	print "i=%s" % i
		if c == 1:
                        print "collision with i=%s!" % i
			return i ## NOTE : returns collided entity (single)
		self.relativex = self.prevx
		self.relativey = self.prevy
	return None

    def isroomdownexit(self):
	if self.relativey < - 320:### and self.relativey < 20:
		return 1
	return 0

    def setxyfromup(self):#FIXME
        self.relativex = -400
	self.relativey = -200
	
	
    def exit(self, game):
        print "x=%d y=%d" % (self.relativex,self.relativey)
        if self.isroomupexit():
	    self.setxyfromup()	    
	    return 1.1
	else:
	    return 0


    def talkto(self):#FIXME needs font
            print "talk to in maproom 6"
            ## return self.koboldwiz
            self.mithran.talkcounter = 1 # FIXME public var
            return self.mithran

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from maproom import *
from knight import *
from blackknight import *
from demon import *
from bombman import *
from turtleflying import *
from ghost1 import *
from ghostwandering import *
from ghostcircling import *
from maproom2 import *
from dungeonmasterkey import *
from dungeonkey1 import *
from mithran import *

class Maproom1_2(Maproom):
    "Room with a (big) map - Towards second south of Knight's Castle"
    def __init__(self,x,y):
        Maproom.__init__(self,x,y)
        self.background = pygame.image.load('./pics/room-bg1_2.bmp').convert()
	self.gameobjects.append(Dungeonwall(0,0,100,300))
	self.gameobjects.append(Dungeonwall(0,200,300,100))
	     
    def draw(self,screen):
        screen.blit(self.background, (0+self.relativex, 0+self.relativey))
        for i in self.gameobjects:
	    if i:
                i.draw(screen,self)
 
    def collide(self, player):
	for i in self.gameobjects:
	    if i != None:
		i.update(self)	
	for i in self.gameobjects:
	    if i!= None:
	    	id = i.collide(self,player)
		self.relativex = self.prevx
		self.relativey = self.prevy
		return id
	return 0

    def pickup(self, player):###FIX for each room
        for o in self.gameobjects:
            if (o and o.collide(self, player)):##FIX o.colidepickup
                id = o.pickup(self)
                self.dungeonkey1 = 1
		return id
        return 0
    
    def exit(self, game):
        # FIX
	return 0

    def removeobject(self, o):
        for i in (0,len(self.gameobjects)-1):
            print "o=%s self.gameobjects[i]=%s i=%d" % (o,self.gameobjects[i],i)
            if self.gameobjects[i] == o:
                print "PICKUP or die"
                self.gameobjects[i] = None
		return 

    def collidesword(self,room,player):
        for i in self.gameobjects:
	    if i!= None:
	    	c = i.collide(room,player)
	    	print "i=%s" % i
		if c == 1:
                        print "collision with i=%s!" % i
			return i ## NOTE : returns collided entity (single)
		self.relativex = self.prevx
		self.relativey = self.prevy
	return None

    def isroomdownexit(self):
	if self.relativey < - 100:### and self.relativey < 20:
		return 1
	return 0

    def setxyfromup(self):#FIXME
        self.relativex = -400
	self.relativey = -200
	
	
    def exit(self, game):
        print "x=%d y=%d" % (self.relativex,self.relativey)
        if self.isroomupexit():
	    self.setxyfromup()	    
	    return 1.1
	elif self.isroomdownexit():
	    self.setxyfromdown()	    
	    return 1.3
	else:
	    return 0

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from maproom import *
from knight import *
from mongbat import *
from maproom2 import *
from dungeonmasterkey import *
from gohma import *
from gohmaup import *
from box import *

class Maproom12(Maproom):
    "Room with a (big) map"
    def __init__(self,x,y):
        Maproom.__init__(self,x,y)
        self.background = pygame.image.load('./pics/room-bg12.bmp').convert()
        self.gameobjects.append(Dungeonwall(0,0,100,900))
	self.gameobjects.append(Dungeonwall(200,0,100,900))


    def draw(self,screen):
        screen.blit(self.background, (0+self.relativex, 0+self.relativey))
        for i in self.gameobjects:
	    if i:
                i.draw(screen,self)
 
    def collide(self, player):
	for i in self.gameobjects:
	    if i != None:
		i.update(self)	
	for i in self.gameobjects:
            if i != None:
                id = i.collide(self,player)
		return id
		self.relativex = self.prevx
		self.relativey = self.prevy
	return 0

##    def pickup(self, player):
##        for o in self.gameobjects:
##            if (o and o.collidepickup(self, player)):
##                o.pickup(self)
##                return
##

    def setxyfromup(self):
        self.relativex = 0
        self.relativey = -700
   
    def exit(self, game):
        if self.isroomupexit():
	    self.setxyfromup()
	    return 13
	#Trap door: elif self.isroomdownexit():
	#    self.setxyfromdown()	
	#    return 11
	else:
	    return 0

    def removeobject(self, o):
        for i in (0,len(self.gameobjects)-1):
            if (self.gameobjects[i] and self.gameobjects[i] == o):
                print "PICKUP"
                self.gameobjects[i] = None

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from maproom import *
from knight import *
from mongbat import *
from maproom2 import *
from dungeonmasterkey import *
from gohma import *
from gohmaup import *
from box import *
from archgohma import *
from demon import *
from mithranhouse import *
from toadstool import *

class Maproom13(Maproom):
    "Room with a (big) map"
    def __init__(self,x,y):
        Maproom.__init__(self,x,y)
        self.background = pygame.image.load('./pics/room-bg13.bmp').convert()
        ##  upper wall
        b = Box(0,0,1000,300)
	b.setimage('./pics/nopicture.bmp',0,0,255)
	## down wall
	b = Box(0,1000,1000,40)
	b.setimage('./pics/nopicture.bmp',0,0,255)
	##  left wall
	b = Box(0,0,40,1000)
	b.setimage('./pics/nopicture.bmp',0,0,255)
	##  right wall
	b = Box(1000,0,40,1000)
	b.setimage('./pics/nopicture.bmp',0,0,255)

	self.gameobjects.append(b)
	## arch gohmas
	self.gameobjects.append(ArchGohma(300,300))
	self.gameobjects.append(ArchGohma(100,700))
	self.gameobjects.append(ArchGohma(700,400))
	self.gameobjects.append(ArchGohma(700,700))
	## possessed demonic knights
	self.gameobjects.append(Demon(300,400))
	self.gameobjects.append(Demon(400,400))
	self.gameobjects.append(Demon(500,400))
	self.gameobjects.append(Demon(600,400))
	## House of Mithran
	self.gameobjects.append(Mithranhouse(500,500,200,200))
	## Giant Toadstools
	self.gameobjects.append(Toadstool(600,400))
	self.gameobjects.append(Toadstool(700,400))
	self.gameobjects.append(Toadstool(600,500))
	self.gameobjects.append(Toadstool(60,700))
	self.gameobjects.append(Toadstool(248,450))
	self.gameobjects.append(Toadstool(80,800))
	self.gameobjects.append(Toadstool(220,480))
	self.gameobjects.append(Toadstool(300,500))
	self.gameobjects.append(Toadstool(210,550))
	self.gameobjects.append(Toadstool(780,780))
	self.gameobjects.append(Toadstool(648,350))
	self.gameobjects.append(Toadstool(805,630))
	
    def draw(self,screen):
        screen.blit(self.background, (0+self.relativex, 0+self.relativey))
        for i in self.gameobjects:
	    if i:
                i.draw(screen,self)
 
    def collide(self, player):
	for i in self.gameobjects:
	    if i != None:
		i.update(self)	
	for i in self.gameobjects:
            if i != None:
                id = i.collide(self,player)
                self.relativex = self.prevx
		self.relativey = self.prevy
		return id
	return 0

    def isroomdownexit(self):
	if self.relativex  <= 100 and self.relativey < -1080:### and self.relativey < 20:
		return 1
	return 0

    def setxyfromdown(self):
        self.relativex = 0
	self.y = 80

    def isroomhouseexit(self):
	if self.relativex  < -400 and self.relativex > - 600 and self.relativey < -400 and self.relativey > - 600:### and self.relativey < 20:
		return 1
	return 0

    def setxyfromhouse(self):
        self.relativex = 0
	self.relativey = 0
	
	
    def exit(self, game):
        print "x=%d y=%d" % (self.relativex,self.relativey)
        if self.isroomdownexit():
	    self.setxyfromdown()	    
	    return 12
	if self.isroomhouseexit():
	    self.setxyfromhouse()	    
	    return 14
	#FIXME Trap door: elif self.isroomdownexit():
	#    self.setxyfromdown()	
	#    return 11
	else:
	    return 0

    def removeobject(self, o):
        for i in (0,len(self.gameobjects)-1):
            if (self.gameobjects[i] and self.gameobjects[i] == o):
                print "PICKUP"
                self.gameobjects[i] = None

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from maproom import *
from knight import *
from blackknight import *
from demon import *
from bombman import *
from turtleflying import *
from ghost1 import *
from ghostwandering import *
from ghostcircling import *
from maproom2 import *
from dungeonmasterkey import *
from dungeonkey1 import *
from mithran2 import *

class Maproom14(Maproom):
    "Room with a (big) map"
    def __init__(self,x,y):
        Maproom.__init__(self,x,y)
        self.background = pygame.image.load('./pics/room-bg14.bmp').convert()
        ###	self.gameobjects.append(Bombman(100,50))
###	self.gameobjects.append(Bombman(200,100))
###	self.gameobjects.append(Bombman(100,150))
        self.mithran = Mithran2(110,120)
	self.gameobjects.append(self.mithran)
	self.gameobjects.append(Dungeonwall(0,0,300,100))
	self.gameobjects.append(Dungeonwall(200,0,100,300))
	self.gameobjects.append(Dungeonwall(0,0,100,300))
	self.gameobjects.append(Dungeonwall(0,200,300,100))
	     
    def draw(self,screen):
        screen.blit(self.background, (0+self.relativex, 0+self.relativey))
        for i in self.gameobjects:
	    if i:
                i.draw(screen,self)
 
    def collide(self, player):
	for i in self.gameobjects:
	    if i != None:
		i.update(self)	
	for i in self.gameobjects:
	    if i!= None:
	    	id = i.collide(self,player)
		self.relativex = self.prevx
		self.relativey = self.prevy
		return id
	return 0

    def pickup(self, player):###FIX for each room
        for o in self.gameobjects:
            if (o and o.collide(self, player)):##FIX o.colidepickup
                id = o.pickup(self)
                self.dungeonkey1 = 1
		return id
        return 0
    
    def exit(self, game):
        # FIX
	return 0

    def removeobject(self, o):
        for i in (0,len(self.gameobjects)-1):
            print "o=%s self.gameobjects[i]=%s i=%d" % (o,self.gameobjects[i],i)
            if self.gameobjects[i] == o:
                print "PICKUP or die"
                self.gameobjects[i] = None
		return 

    def collidesword(self,room,player):
        for i in self.gameobjects:
	    if i!= None:
	    	c = i.collide(room,player)
	    	print "i=%s" % i
		if c == 1:
                        print "collision with i=%s!" % i
			return i ## NOTE : returns collided entity (single)
		self.relativex = self.prevx
		self.relativey = self.prevy
	return None

    def isroomhouseexit(self):
	if self.relativex  < 60 and self.relativex > -10 and self.relativey < -70 and self.relativey > - 130:### and self.relativey < 20:
		return 1
	return 0

    def setxyfromhouse(self):
        self.relativex = -600
	self.relativey = -500
	
	
    def exit(self, game):
        print "x=%d y=%d" % (self.relativex,self.relativey)
        if self.isroomhouseexit():
	    self.setxyfromhouse()	    
	    return 13
	#Trap door: elif self.isroomdownexit():
	#    self.setxyfromdown()	
	#    return 11
	else:
	    return 0


    def talkto(self):#FIXME needs font
            print "talk to in maproom 6"
            ## return self.koboldwiz
            self.mithran.talkcounter = 1 # FIXME public var
            return self.mithran

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from maproom import *
from tree import *
from tree2 import *
from dungeonentrance1 import *
from maproomdungeon import *
from maproomdungeonnorthwall import *
from goblin1 import *
from goblin2 import *
from goblin3 import *
from tilebox import *
from rope import *
#from snake1 import *
from rubysword import *
from beholder import *
from beholderbat import *
from abeille import *
from abeille2 import *
from bullfrog import *
from bullfrog2 import *
from bullfrog3 import *
from bullfrog4 import *
from bullfrog5 import *
from scorpionred1 import *
from scorpionred2 import *
from scorpionred3 import *
from scorpionred4 import *
from spider1 import *
from spider2 import *
from cavespider1 import *
from skeleton1 import *
from roadsign import *
from ghostwandering import *
from ghostcircling import *
from ghostcircling2 import *

class Maproom1(MaproomDungeon):
    "Room with a (big) map"
    def __init__(self,x,y):
        MaproomDungeon.__init__(self,x,y)
        self.background = pygame.image.load('./pics/bg1-2000x600.bmp').convert()
        ###self.northwall1 = Tilebox(1,1,60,48,16,1,'./pics/walldungeonnorth2-beholderglass-60x48.bmp')
##        self.northwall1 = Tilebox(1,1,60,48,13,1,'./pics/walldungeonnorth1-60x48.bmp')
##        self.southwall1 = Tilebox(1,200,30,48,13,1,'./pics/walldungeonsouth1-30x48.bmp')
##        self.westwall1 = Tilebox(360,200,48,60,1,10,'./pics/walldungeonwest1-48x60.bmp')
##        self.eastwall1 = Tilebox(775,1,48,60,1,14,'./pics/walldungeoneast1-48x60.bmp')
##        self.tileboxes.append(self.northwall1)
##        self.tileboxes.append(self.westwall1)
##        self.tileboxes.append(self.eastwall1)
##        self.tileboxes.append(self.southwall1)

        # left NOTE!!! : boxes collide so put them after enemies and roadsigns !
##        self.gameobjects.append(CaveSpider1(150,90))
##        self.gameobjects.append(CaveSpider1(200,90))
##        #self.gameobjects.append(Skeleton1(700,525))
        #self.gameobjects.append(Skeleton1(2000,525))
        self.h = -500
               


##        self.gameobjects.append(Abeille2(600,280)) 
##        self.gameobjects.append(Abeille2(700,280))
##
##        self.gameobjects.append(Abeille2(1000,280)) 
##        self.gameobjects.append(Abeille2(1100,280)) 
        #self.gameobjects.append(Bullfrog(1100,300))
        
##        self.gameobjects.append(Bullfrog(1800,300))
##        self.gameobjects.append(Bullfrog(2000,300))
        

        # left NOTE!!! : boxes collide so put them after enemies !
        self.roadsign = RoadSign(920,540)#FIXME
        self.gameobjects.append(self.roadsign)

        self.gameobjects.append(Bullfrog(700,340))
        self.gameobjects.append(Bullfrog(1800,340))
        self.gameobjects.append(Bullfrog(1500,340))
        self.gameobjects.append(Bullfrog5(170,270,500))
        self.gameobjects.append(Bullfrog4(100,0,700))
        
        #self.gameobjects.append(GhostWandering(100,500))
        #self.gameobjects.append(GhostWandering(150,500))
        self.gameobjects.append(GhostCircling(100,500,150,500))

        self.gameobjects.append(Box(0,400,900,12))
        self.gameobjects.append(Box(950,400,1050,12))
        
        # ropes       
        #self.ropes.append(Rope(980,375,140))
        # floor under rope
        self.gameobjects.append(Box(0,610,2400,12))
        # outer walls
        self.gameobjects.append(Box(0,0,12,1000))
        self.gameobjects.append(Box(950,0,12,1000))

        self.locationtext = "Woods of the Moon Elves"
        
    def draw(self,screen,player):
        sleep(0.05) # FIXME in each room
        # draw bg
        screen.blit(self.background, (0+self.relativex, 0+self.relativey))
        # draw walls
        MaproomDungeon.draw(self,screen)
        for t in self.tileboxes:
            t.draw(screen,self.relativex,self.relativey)
        #self.southwall1.draw(screen,self.relativex,self.relativey)
        # draw gameobjects
        for i in self.gameobjects:
	    if i != None:
		i.update(self,player)
		i.draw(screen,self)
	for i in self.ropes:
	    if i != None:
		i.update(self,player)
		i.draw(screen,self)
		
    def isroomdoorexitleft(self,game):
	if self.relativex  > 160 and self.relativex < 270 and self.relativey < -200:
		return 1
	return 0

    def setxyfromdoorleft(self,game):
       game.x = -530
       game.y = 40

    def isroomdoorexitright(self,game):
	if self.relativex  < -1500 and self.relativex > -1550 and self.relativey < -200:
		return 1
	return 0

    def setxyfromdoorright(self,game):
        game.x = 0
        game.y = 0

    def exit(self, game):
	if self.isroomdoorexitleft(game):
		self.setxyfromdoorleft(game)
		return 2.1 #NOTE1
	if self.isroomdoorexitright(game):
		self.setxyfromdoorright(game)
		return 3
	return 0 
 
    def collidesword(self,player):
        for i in self.gameobjects:
	    if i!= None:
	    	id = i.collidewithsword(self,player)
		#self.relativex = self.prevx
		#self.relativey = self.prevy
		return i ## NOTE : returns collided entity (single)
	return None


    def removeobject(self, o):
        for i in range(0,len(self.gameobjects)):
            if self.gameobjects[i] == o:
                self.gameobjects[i] = None

    def talkto(self):#FIXME needs font
            print "talk to in maproom 1"
            ## return self.koboldwiz
            self.roadsign.talkcounter = 1
            return self.roadsign

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from maproom import *
from tree import *
from tree2 import *
from dungeonentrance1 import *
from maproomdungeon import *
from dungeonkey1 import *
from dungeonmasterkey import *
from maproomdungeonnorthwall import *
from goblin1 import *
from goblin2 import *
from goblin3 import *
from tilebox import *
from rope import *
#from snake1 import *
from dungeondoor1 import *
from rubysword import *
from beholder import *
from beholderbat import *
from abeille import *
from abeille2 import *
from bullfrog import *
from scorpionred1 import *
from scorpionred2 import *
from scorpionred3 import *
from scorpionred4 import *
from skeleton1 import *
from skeleton2 import *
from skeleton3 import *
from spider1 import *
from spider2 import *
from cavespider1 import *
from cavespider2 import *
from roadsign import *
from movingplatform import *
from movingplatform2 import *
from chest1 import *
from healingpotion import *
from bow1 import *
from knightfighting import *
from ghostcircling import *
from ghostcircling2 import *
from ghostwandering import *

class Maproom2_1(MaproomDungeon):
    "Room with a (big) map - Dragonback Mountains room 1"
    def __init__(self,x,y):
        MaproomDungeon.__init__(self,x,y)
        self.background = pygame.image.load("./pics/bg3-4000x1500.bmp").convert()
        ###self.northwall1 = Tilebox(1,1,60,48,16,1,'./pics/walldungeonnorth2-beholderglass-60x48.bmp')
##        self.northwall1 = Tilebox(1,1,60,48,13,1,'./pics/walldungeonnorth1-60x48.bmp')
##        self.southwall1 = Tilebox(1,200,30,48,13,1,'./pics/walldungeonsouth1-30x48.bmp')
##        self.westwall1 = Tilebox(360,255,48,60,1,10,'./pics/walldungeonwest1-48x60.bmp')
##        self.eastwall1 = Tilebox(775,1,48,60,1,14,'./pics/walldungeoneast1-48x60.bmp')
##        self.tileboxes.append(self.northwall1)
##        self.tileboxes.append(self.westwall1)
##        self.tileboxes.append(self.eastwall1)
##        self.tileboxes.append(self.southwall1)
        self.h = -1150
        

        # left NOTE!!! : boxes collide so put them after enemies and roadsigns !
        
        #self.gameobjects.append(GhostCircling2(100,250))
        self.gameobjects.append(GhostWandering(100,250))

        self.gameobjects.append(Skeleton3(1000,450,Box(1000,400,1000,400)))

        self.gameobjects.append(Skeleton3(1000,270,Box(900,0,1000,400)))
        self.gameobjects.append(Skeleton3(1000,270,Box(1000,0,1000,400)))
        self.gameobjects.append(Skeleton3(1100,270,Box(1100,0,1000,400)))
        self.gameobjects.append(Skeleton3(1260,270,Box(1205,0,1000,400)))
        self.gameobjects.append(Skeleton3(1300,270,Box(1300,0,1000,400)))
        self.gameobjects.append(Skeleton3(1400,270,Box(1400,0,1000,400)))
        self.gameobjects.append(Skeleton3(1500,270,Box(1500,0,1000,400)))

        self.gameobjects.append(Skeleton3(1000,270,Box(900,0,100,400)))
        self.gameobjects.append(Skeleton3(1100,270,Box(1000,0,100,400)))
        self.gameobjects.append(Skeleton3(1500,270,Box(1400,0,100,400)))
        self.gameobjects.append(Skeleton3(1600,270,Box(1500,0,100,400)))
        
        self.gameobjects.append(Skeleton3(2000,500,Box(2000,400,100,300)))
        self.gameobjects.append(Skeleton3(2500,500,Box(2500,400,100,300)))
        self.gameobjects.append(Skeleton3(2600,500,Box(2600,400,100,300)))
        self.gameobjects.append(Skeleton3(2700,500,Box(2700,400,100,300)))
        self.gameobjects.append(Skeleton3(3300,500,Box(3200,300,400,400)))
        self.gameobjects.append(Skeleton3(3320,500,Box(3220,300,400,400)))
        self.gameobjects.append(Skeleton3(3500,500,Box(3400,300,400,400)))
        self.gameobjects.append(Skeleton3(3700,500,Box(3600,300,400,400)))
        self.gameobjects.append(Skeleton3(3800,500,Box(3700,300,400,400)))
        self.gameobjects.append(Skeleton3(3900,500,Box(3800,300,400,400)))
        
        self.gameobjects.append(Spider2(3200,500))
        self.gameobjects.append(Spider2(2400,720))
        self.gameobjects.append(Spider1(1500,300))
        self.gameobjects.append(Spider1(1400,300))
        self.gameobjects.append(Spider1(500,300))
        self.gameobjects.append(Spider1(200,250))
        self.gameobjects.append(KnightFighting(1400,250))
        self.gameobjects.append(KnightFighting(3200,250))
        self.gameobjects.append(Spider2(1800,300))
        self.gameobjects.append(Spider2(1700,300))
        self.gameobjects.append(CaveSpider1(150,90))
        self.gameobjects.append(CaveSpider1(200,90))
    
        self.gameobjects.append(Spider1(3200,300))
        self.gameobjects.append(Spider1(3800,300))

        self.gameobjects.append(CaveSpider2(3050,90))
        self.gameobjects.append(CaveSpider2(3000,90))

        self.gameobjects.append(CaveSpider2(1200,750))
        self.gameobjects.append(CaveSpider2(1250,750))
        
        self.gameobjects.append(Skeleton1(1250,750))
                
        # NOTE !! set items after because they collid ewit hfighting
        self.gameobjects.append(HealingPotion(50,500))
        self.gameobjects.append(HealingPotion(1850,880))
        self.gameobjects.append(Dungeonkey1(3000,80))
        self.gameobjects.append(Dungeondoor1(3705,1275,50,50))

        self.gameobjects.append(GhostCircling(1100,950,1100,950))
##               
##        # left NOTE!!! : boxes collide so put them after enemies !
        ####### upper 
        self.gameobjects.append(Box(0,330,750+715,12))
        self.gameobjects.append(Box(750+785,330,365,12))
        self.gameobjects.append(Box(750+1000,330,450,12))
        self.gameobjects.append(Box(2250,330,1700,12))
        # upperest platform
        self.gameobjects.append(Box(2790,170,400,12))
        # upper left room wall
        self.gameobjects.append(Box(1750,0,12,320))
        # outer right room wall
        self.gameobjects.append(Box(3980,0,12,4000))
        # roof
        self.gameobjects.append(Box(0,0,12,2200))
        # ropes
        self.ropes.append(Rope(2780,90,200))
        self.ropes.append(Rope(750+720,0,520))
        ####### upper 2
        self.gameobjects.append(Box(0,580,200,12))
        self.gameobjects.append(Box(700+0,580,765,12))
        self.gameobjects.append(Box(750+785+50,580,2330,12))
        #self.gameobjects.append(Box(750+785+50+590+50,580,1655,12))
        # ropes
        self.ropes.append(Rope(2210,200,520))
        ####### upper 3
        self.gameobjects.append(Box(0,760,2150,12))
        self.gameobjects.append(Box(2300,760,1075,12))
        # ropes
        self.ropes.append(Rope(3400,720,520))
        ####### upper 4
        self.gameobjects.append(Box(1750,955,320,12))
        self.gameobjects.append(Box(2050,1005,1325,12))
        ### upper 4 short wall
        self.gameobjects.append(Box(1980,935,50,70))
        # wall (corner)
        self.gameobjects.append(Box(1750,800,50,200))

        ####### upper 5
        self.gameobjects.append(Box(1100,1190,1440,12))
        ####### upper 5 wall + corner + rope
        self.gameobjects.append(Box(900,800,24,200))
        self.gameobjects.append(Box(900,1040,300,12))
        self.ropes.append(Rope(1150,900,260))
        ####### upper 6
        self.gameobjects.append(Box(2550,1360,1460,12))
        # ropes
        self.ropes.append(Rope(2560,1050,320))
        # floor under rope
        # moving platforms
        self.movingplatforms.append(Movingplatform(200,550,100,42,200,670))
        self.movingplatforms.append(Movingplatform2(3900,1150,100,42,500,1320)) 

        self.locationtext = "Moon Elf Mountains"

    def draw(self,screen,player):
        sleep(0.02) # FIXME in each room
        # draw bg
        screen.blit(self.background, (0+self.relativex, 0+self.relativey))
        # draw walls
        MaproomDungeon.draw(self,screen)
        for t in self.tileboxes:
            t.draw(screen,self.relativex,self.relativey)
        #self.southwall1.draw(screen,self.relativex,self.relativey)
        # draw gameobjects
        for i in self.gameobjects:
	    if i != None:
		i.update(self,player)
		i.draw(screen,self)
	for i in self.ropes:
	    if i != None:
		i.update(self,player)
		i.draw(screen,self)
	for i in self.movingplatforms:
            if i != None:
                i.update(self,player)
                i.draw(screen,self,player)
                
                
    def isroomdoorexitleft(self,game):
	if self.relativex  > 180-750 and self.relativex < 250-750 and self.relativey >= -20:
		return 1
	return 0

    def setxyfromdoorleft(self,game):
        game.x = 150
	game.y = -200

    def isroomdoorexit(self,game):
	if self.relativex  < -720 and self.relativex > - 820 and self.relativey < -590 and self.relativey > -690:
		return 1
	return 0

    def setxyfromdoor(self,game):
        game.x = 250
        game.y = -10

    def isroomdoorsewerexit(self,game):
        if game.room.inventorykey1:
        	if self.relativex  < -3320 and self.relativex > -3460 and self.relativey < -970 and self.relativey > -1060:
                    return 1
	return 0

    def setxyfromdoorsewer(self,game):
        game.x = 250
        game.y = -10


    def exit(self, game):
	if self.isroomdoorexitleft(game):
		self.setxyfromdoorleft(game)
		return 1
	if self.isroomdoorexit(game):
		self.setxyfromdoor(game)
		return 2.2
	if self.isroomdoorsewerexit(game):
		self.setxyfromdoorsewer(game)
		return 2
	return 0 
 
    def collidesword(self,player):
        for i in self.gameobjects:
	    if i!= None:
	    	id = i.collidewithsword(self,player)
		#self.relativex = self.prevx
		#self.relativey = self.prevy
		return i ## NOTE : returns collided entity (single)
	return None


    def removeobject(self, o):
        for i in range(0,len(self.gameobjects)):
            if self.gameobjects[i] == o:
                self.gameobjects[i] = None

    def talkto(self):#FIXME needs font
        return None
##          print "talk to in maproom 2_1"
##            ## return self.koboldwiz
##            self.roadsign.talkcounter = 1
##            return self.roadsign

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from maproom import *
from tree import *
from tree2 import *
from dungeonentrance1 import *
from maproomdungeon import *
from maproomdungeonnorthwall import *
from goblin1 import *
from goblin2 import *
from goblin3 import *
from tilebox import *
from rope import *
from bow1 import *
#from snake1 import *
from rubysword import *
from beholder import *
from beholderbat import *
from abeille import *
from abeille2 import *
from bullfrog import *
from scorpionred1 import *
from scorpionred2 import *
from skeleton1 import *

from roadsign import *

class Maproom2(MaproomDungeon):
    "Room with a (big) map"
    def __init__(self,x,y):
        MaproomDungeon.__init__(self,x,y)
        self.background = pygame.image.load("./pics/bg2-850x600.bmp").convert()
        ###self.northwall1 = Tilebox(1,1,60,48,16,1,'./pics/walldungeonnorth2-beholderglass-60x48.bmp')
##        self.northwall1 = Tilebox(1,1,60,48,13,1,'./pics/walldungeonnorth1-60x48.bmp')
##        self.southwall1 = Tilebox(1,200,30,48,13,1,'./pics/walldungeonsouth1-30x48.bmp')
##        self.westwall1 = Tilebox(360,200,48,60,1,10,'./pics/walldungeonwest1-48x60.bmp')
##        self.eastwall1 = Tilebox(775,1,48,60,1,14,'./pics/walldungeoneast1-48x60.bmp')
##        self.tileboxes.append(self.northwall1)
##        self.tileboxes.append(self.westwall1)
##        self.tileboxes.append(self.eastwall1)
##        self.tileboxes.append(self.southwall1)

        # left NOTE!!! : boxes collide so put them after enemies and roadsigns !
        #self.gameobjects.append(Skeleton1(700,315))
        #self.gameobjects.append(Skeleton1(2000,315))
        self.h = -600
        # FIXME1 do not collide with other enemies for boxes

        self.gameobjects.append(Bow1(800,280))
        
        # left NOTE!!! : boxes collide so put them after enemies !
        self.gameobjects.append(Box(0,375,260,12))
        self.gameobjects.append(Box(310,375,130,12))
        self.gameobjects.append(Box(450,375,440,12))


        # left wall
        self.gameobjects.append(Box(0,0,12,480))
        # right wall
        self.gameobjects.append(Box(960,0,12,480))

        # ropes       
        #self.ropes.append(Rope(980,455,140))
        # floor under rope
                
        self.locationtext = "Moon Elf Mountains"

    def draw(self,screen,player):
        sleep(0.05) # FIXME in each room
        # draw bg
        screen.blit(self.background, (0+self.relativex, 0+self.relativey))
        # draw walls
        MaproomDungeon.draw(self,screen)
        for t in self.tileboxes:
            t.draw(screen,self.relativex,self.relativey)
        #self.southwall1.draw(screen,self.relativex,self.relativey)
        # draw gameobjects
        for i in self.gameobjects:
	    if i != None:
		i.update(self,player)
		i.draw(screen,self)
	for i in self.ropes:
	    if i != None:
		i.update(self,player)
		i.draw(screen,self)
		
    def isroomdoorexitleft(self,game):
	if self.relativex  > 220 and self.relativex < 250:
		return 1
	return 0

    def setxyfromdoorleft(self,game):
        game.x = -3350
	game.y = -1000

    def isroomdoorexitright(self,game):
        print "foo %s" % self.relativex
	if self.relativex  < -520:
		return 1
	return 0

    def setxyfromdoorright(self,game):
        game.x = -600
        game.y = 40

    def exit(self, game):
	if self.isroomdoorexitleft(game):
		self.setxyfromdoorleft(game)
		return 2.1
##	if self.isroomdoorexitright():
##		self.setxyfromdoorright(game)
##		return 2.1
	return 0 
 
    def collidesword(self,player):
        for i in self.gameobjects:
	    if i!= None:
	    	id = i.collidewithsword(self,player)
		#self.relativex = self.prevx
		#self.relativey = self.prevy
		return i ## NOTE : returns collided entity (single)
	return None


    def removeobject(self, o):
        for i in range(0,len(self.gameobjects)):
            if self.gameobjects[i] == o:
                self.gameobjects[i] = None

    def talkto(self):#FIXME needs font
          return None

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from maproom import *
from blackknight import *
from bombman import *
from mongbat import *
from maproom2 import *
from dungeonmasterkey import *

class Maproom3(Maproom):
    "Room with a (big) map"
    def __init__(self,x,y):
        Maproom.__init__(self,x,y)
        self.background = pygame.image.load('./pics/room-bg3.bmp').convert()
        self.gameobjects.append(Dungeonwall(0,0,300,40))
	self.gameobjects.append(Dungeonwall(0,260,300,40))
	self.gameobjects.append(Dungeonwall(0,0,40,300))
	self.gameobjects.append(Dungeonwall(260,0,40,300))
        self.gameobjects.append(BlackKnight(100,50))
	self.gameobjects.append(BlackKnight(200,100))
	self.gameobjects.append(BlackKnight(100,150))
	self.gameobjects.append(BlackKnight(200,200))


    def draw(self,screen):
        screen.blit(self.background, (0+self.relativex, 0+self.relativey))
        for i in self.gameobjects:
	    if i:
                i.draw(screen,self)
 
    def collide(self, player):
	for i in self.gameobjects:
	    if i != None:
		i.update(self)	
	for i in self.gameobjects:
	    if i!= None:
	    	id = i.collide(self,player)
	    	self.relativex = self.prevx
		self.relativey = self.prevy
		return id
	return 0#FIX

##    def pickup(self, player):
##        for o in self.gameobjects:
##            if (o and o.collidepickup(self, player)):
##                o.pickup(self)
##                return

    
    def exit(self, game):
        if self.isroomrightexit():
	    self.setxyfromright()	
	    return 2
	elif self.isroomleftexit():
	    self.setxyfromleft()	
	    return 4 
	else:
	    return 0

    def removeobject(self, o):
        for i in (0,len(self.gameobjects)-1):
            if (self.gameobjects[i] and self.gameobjects[i] == o):
                print "PICKUP"
                self.gameobjects[i] = None

    def collidesword(self,room,player):
        for i in self.gameobjects:
	    if i!= None:
	    	c = i.collide(room,player)
		if c == 1:
			return i ## NOTE : returns collided entity (single)
		self.relativex = self.prevx
		self.relativey = self.prevy
	return None

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from maproom import *
from knight import *
from blackknight import *
from maproom2 import *
from dungeonmasterkey import *

class Maproom4(Maproom):
    "Room with a (big) map"
    def __init__(self,x,y):
        Maproom.__init__(self,x,y)
        self.background = pygame.image.load('./pics/room-bg4.bmp').convert()
        self.gameobjects.append(Dungeonwall(0,0,300,40))
	self.gameobjects.append(Dungeonwall(0,260,300,40))
	self.gameobjects.append(Dungeonwall(0,0,40,300))
	self.gameobjects.append(Dungeonwall(260,0,40,300))
##FIX	self.gameobjects.append(Dungeonstatue1(200,100))
##	self.gameobjects.append(Dungeonstatue1(60,100))
	self.gameobjects.append(BlackKnight(100,50))
	self.gameobjects.append(BlackKnight(200,100))
	self.gameobjects.append(BlackKnight(100,150))
	self.gameobjects.append(BlackKnight(200,200))
 
    def draw(self,screen):
        screen.blit(self.background, (0+self.relativex, 0+self.relativey))
        for i in self.gameobjects:
	    if i:
                i.draw(screen,self)
 
    def collide(self, player):
	for i in self.gameobjects:
	    if i != None:
		i.update(self)	
	for i in self.gameobjects:
	    if i!= None:
	    	id = i.collide(self,player)
		self.relativex = self.prevx
		self.relativey = self.prevy
		return id
	return 0

##    def pickup(self, player):
##        for o in self.gameobjects:
##            if (o and o.collidepickup(self, player)):
##                o.pickup(self)
##                return
##    

    def exit(self, game):
        if self.isroomleftexit():
	    self.setxyfromleft()	
	    return 5
        elif self.isroomrightexit():
	    self.setxyfromright()	
	    return 3 
	else:
	    return 0

    def removeobject(self, o):
        for i in (0,len(self.gameobjects)-1):
            if (self.gameobjects[i] and self.gameobjects[i] == o):
                print "PICKUP"
                self.gameobjects[i] = None

    def removeobject(self, o):
        for i in (0,len(self.gameobjects)-1):
            if (self.gameobjects[i] and self.gameobjects[i] == o):
                print "PICKUP"
                self.gameobjects[i] = None

    def collidesword(self,room,player):
        for i in self.gameobjects:
	    if i!= None:
	    	c = i.collide(room,player)
		if c == 1:
			return i ## NOTE : returns collided entity (single)
		self.relativex = self.prevx
		self.relativey = self.prevy
	return None

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from maproom import *
from knight import *
from blackknight import *
from demon import *
from bombman import *
from turtleflying import *
from ghost1 import *
from ghostwandering import *
from ghostcircling import *
from maproom2 import *
from dungeonmasterkey import *
from dungeonkey1 import *

class Maproom5(Maproom):
    "Room with a (big) map"
    def __init__(self,x,y):
        Maproom.__init__(self,x,y)
        self.background = pygame.image.load('./pics/room-bg5.bmp').convert()
        ###	self.gameobjects.append(Bombman(100,50))
###	self.gameobjects.append(Bombman(200,100))
###	self.gameobjects.append(Bombman(100,150))
	self.gameobjects.append(GhostWandering(200,200))
	self.gameobjects.append(GhostWandering(200,240))
	self.gameobjects.append(Ghostcircling(20,20))
	self.gameobjects.append(Dungeonwall(0,0,300,10))
	self.gameobjects.append(Dungeonwall(0,290,300,10))
	self.gameobjects.append(Dungeonwall(0,0,10,300))
	self.gameobjects.append(Dungeonwall(290,0,10,300))
	# NOTE eventually keep last for easy removal
	if not self.dungeonkey1:
            self.gameobjects.append(Dungeonkey1(40,250))
            
    def draw(self,screen):
        screen.blit(self.background, (0+self.relativex, 0+self.relativey))
        for i in self.gameobjects:
	    if i:
                i.draw(screen,self)
 
    def collide(self, player):
	for i in self.gameobjects:
	    if i != None:
		i.update(self)	
	for i in self.gameobjects:
	    if i!= None:
	    	id = i.collide(self,player)
		self.relativex = self.prevx
		self.relativey = self.prevy
		return id
	return 0

    def setxyfromroomtotower(self):
        self.x = 0 
        self.y = -100

    def isroomtowerexit(self):
	if self.relativex > -10 and self.relativex < 15 and self.relativey > 40:
		return 1
	return 0


    def pickup(self, player):###FIX for each room
        for o in self.gameobjects:
            if (o and o.collide(self, player)):##FIX o.colidepickup
                id = o.pickup(self)
                self.dungeonkey1 = 1
		return id
        return 0
    
    def exit(self, game):
        if self.isroomrightexit():
	    self.setxyfromright()	
	    return 4
	elif self.isroomtowerexit():
	    self.setxyfromroomtotower()	
	    return 6
	else:
	    return 0

    def removeobject(self, o):
        for i in (0,len(self.gameobjects)-1):
            print "o=%s self.gameobjects[i]=%s i=%d" % (o,self.gameobjects[i],i)
            if self.gameobjects[i] == o:
                print "PICKUP or die"
                self.gameobjects[i] = None
		return 

    def collidesword(self,room,player):
        for i in self.gameobjects:
	    if i!= None:
	    	c = i.collide(room,player)
	    	print "i=%s" % i
		if c == 1:
                        print "collision with i=%s!" % i
			return i ## NOTE : returns collided entity (single)
		self.relativex = self.prevx
		self.relativey = self.prevy
	return None



# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from maproom import *
from maproom1 import *
from tree import *
from knightstatue1 import *
from dungeonwall import *
from koboldwizard import *
from dungeonstatue2 import *
from dungeonstatue3 import *
from dungeonentrance2 import *
from knight2 import *
from time import *

class Maproom6(Maproom):
    "Room with a (big) map"
    def __init__(self,x,y):
        Maproom.__init__(self,x,y)
        self.background = pygame.image.load('./pics/room-bg6.bmp').convert()
        self.gameobjects.append(Dungeonwall(0,0,300,40))
	self.gameobjects.append(Dungeonwall(0,260,40,300))
	self.gameobjects.append(Dungeonwall(0,0,40,300))
	self.gameobjects.append(Dungeonwall(0,260,300,40))
        self.gameobjects.append(Dungeonstatue2(100,76))
        self.gameobjects.append(Dungeonstatue3(160,76))
        self.gameobjects.append(Dungeonentrance2(130,0))
	#self.koboldwiz = KoboldWizard(100,60)
        #self.gameobjects.append(self.koboldwiz)
	self.knight = Knight2(50,50)
	self.gameobjects.append(self.knight)
        self.flag = 0
 
    def draw(self,screen):
        ###FIX numpy ### a = pygame.surfarray.pixels3d(pygame.display.get_surface())
        ###a = pygame.surfarray.array3d(pygame.display.get_surface())
	###a = pygame.display.get_surface().copy()
        #FIXif self.flag == 1:
        screen.blit(self.background, (0+self.relativex, 0+self.relativey))
        for i in self.gameobjects:
            if i != None:
                i.draw(screen,self)
        return
        
##	
##        for i in range(0,300):
##            for j in range(0,300):
##                ###c = a[j][i]
##                R = 255 >> 1
##                G = 0
##                B = 0
##                color = (R,G,B) ###(c[0],c[1],c[2])
##                
##                pygame.draw.line(pygame.display.get_surface(),color,(j,i),(j,i))
##        pygame.display.update()
##        sleep(.1)
##        for i in range(0,300):
##             for j in range(0,300):
##                ###c = a[j][i]
##                R = 255 >> 2
##                G = 0
##                B = 0
##                color = (R,G,B) ###(c[0],c[1],c[2])
##                
##                pygame.draw.line(pygame.display.get_surface(),color,(j,i),(j,i))
##        pygame.display.update()
##        sleep(.1)
##        for i in range(0,300):
##            for j in range(0,300):
##                ###c = a[j][i]
##                R = 255 >> 2
##                G = 0
##                B = 0
##                color = (R,G,B) ###(c[0],c[1],c[2])
##                
##                pygame.draw.line(pygame.display.get_surface(),color,(j,i),(j,i))
##        pygame.display.update()
##        sleep(.1)
##        for i in range(0,300):
##            for j in range(0,300):
##                ###c = a[j][i]
##                R = 0
##                G = 0
##                B = 0
##                color = (R,G,B) ###(c[0],c[1],c[2])
##                
##                pygame.draw.line(pygame.display.get_surface(),color,(j,i),(j,i))
##	self.flag = 1
	
    def collide(self, player):
	for i in self.gameobjects:
	    if i != None:
		i.update(self)	
	for i in self.gameobjects:
            if i != None:
                c = i.collide(self,player)
                ###FIX in all maproom collisions
		if c != 0:###FIXME put this in other room collides also
                    #print "->i=%s c=%s" % (i,c)
                    return c
		self.relativex = self.prevx
		self.relativey = self.prevy
	return 0

    def exit(self, game):
        if self.isroomupexit():
	    self.setxyfromup()	
	    return 7
	elif self.isroomdownexit():
	    self.setxyfromdown()	
	    return 5
##        if self.relativey > 100 and self.relativex > -10 and self.relativex < 20:
##	    game.setxy(0,80)
##	    return 4
##	elif self.relativey < -100 and self.relativex > -10 and self.relativex < 20:
##	    game.setxy(0,-25)
##	    return 1
##	if self.relativex < -100 and self.relativey > -10 and self.relativey < 20:
##	    game.setxy(0,0)
##	    return 7
	else:
	    return 0

	def talkto(self):#FIXME needs font
            print "talk to in maproom 6"
            ## return self.koboldwiz
            self.knight.talkcounter = 1
            return self.knight

##        def pickup(self, player):
##            for o in self.gameobjects:
##                if (o and o.collidepickup(self, player)):
##                    id = o.pickup(self)
##                    return id
##            return 0

    def removeobject(self, o):
        for i in self.gameobjects:
            if o:
                if o == i:
                    i = None##FIXME1

    def removeentrance2(self):
        self.gameobjects[6] = None
               
    def collidesword(self,room,player):
        for i in self.gameobjects:
	    if i!= None:
	    	c = i.collide(room,player)
		if c == 1:
			return i ## NOTE : returns collided entity (single)
		self.relativex = self.prevx
		self.relativey = self.prevy
	return None

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from maproom import *
from knight import *
from blackknight import *
from maproom2 import *
from brokenwall import *

class Maproom7(Maproom):
    "Room with a (big) map"
    def __init__(self,x,y):
        Maproom.__init__(self,x,y)
        self.background = pygame.image.load('./pics/room-bg7.bmp').convert()
        self.gameobjects.append(Dungeonwall(0,0,300,40))
	self.gameobjects.append(Dungeonwall(0,260,300,40))
	self.gameobjects.append(Dungeonwall(0,0,40,300))
	self.gameobjects.append(Dungeonwall(260,0,40,300))
	###FIX self.gameobjects.append(Dungeonbrokenwall(100,-9))
	###self.gameobjects.append(Dungeonstatue1(150,150))
	self.gameobjects.append(Knight(100,50))
	self.gameobjects.append(Knight(200,100))
	self.gameobjects.append(Knight(100,150))
	self.gameobjects.append(Knight(200,200))
 
    def draw(self,screen):
        screen.blit(self.background, (0+self.relativex, 0+self.relativey))
        for i in self.gameobjects:
	    if i:
                i.draw(screen,self)
 
    def collide(self, player):
	for i in self.gameobjects:
	    if i != None:
		i.update(self)	
	for i in self.gameobjects:
            if i!= None:
                id = i.collide(self,player)
		self.relativex = self.prevx
		self.relativey = self.prevy
		return id
	return 0
    
    def exit(self, game):
        if self.isroomleftexit():
	    self.setxyfromleft()	
	    return 8
	else:
	    return 0 

    
##    def pickup(self, player):
##        for o in self.gameobjects:
##            if (o and o.collidepickup(self, player)):
##                id = o.pickup(self)
##                return id
##        return 0
##    

    def removeobject(self, o):
        for i in (0,len(self.gameobjects)-1):
            if (self.gameobjects[i] and self.gameobjects[i] == o):
                print "PICKUP"
                self.gameobjects[i] = None


    def collidesword(self,room,player):
        for i in self.gameobjects:
	    if i!= None:
	    	c = i.collide(room,player)
		if c == 1:
			return i ## NOTE : returns collided entity (single)
		self.relativex = self.prevx
		self.relativey = self.prevy
	return None

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from maproom import *
from knight import *
from mongbat import *
from maproom2 import *
from dungeonmasterkey import *
from gohma import *
from gohmaup import *

class Maproom8(Maproom):
    "Room with a (big) map"
    def __init__(self,x,y):
        Maproom.__init__(self,x,y)
        self.background = pygame.image.load('./pics/room-bg8.bmp').convert()
        #self.gameobjects.append(Dungeonmasterkey(50,50))
	self.gameobjects.append(Dungeonwall(0,0,300,40))
	self.gameobjects.append(Dungeonwall(0,260,300,40))
	self.gameobjects.append(Dungeonwall(0,0,40,300))
	self.gameobjects.append(Gohma(0,20))
	self.gameobjects.append(GohmaUp(0,200))
##	self.gameobjects.append(Dungeonwall(260,0,40,300))
##	self.gameobjects.append(Mongbat(100,50))
##	self.gameobjects.append(Mongbat(200,100))
##	self.gameobjects.append(Mongbat(100,150))
##	self.gameobjects.append(Mongbat(200,200))


    def draw(self,screen):
        screen.blit(self.background, (0+self.relativex, 0+self.relativey))
        for i in self.gameobjects:
	    if i:
                i.draw(screen,self)
 
    def collide(self, player):
	for i in self.gameobjects:
	    if i != None:
		i.update(self)	
	for i in self.gameobjects:
            if i != None:
                id = i.collide(self,player)
                self.relativex = self.prevx
		self.relativey = self.prevy
		return id
	return 0

##    def pickup(self, player):
##        for o in self.gameobjects:
##            if (o and o.collidepickup(self, player)):
##                o.pickup(self)
##                return
##

    
    def exit(self, game):
        if self.isroomupexit():
	    self.setxyfromup()	
	    return 11
	elif self.isroomrightexit():
            self.setxyfromright()
	    return 7
        elif self.isroomleftexit():
	    self.setxyfromleft()	
	    return 9
	elif self.isroomdownexit():
	    self.setxyfromdown()	
	    return 15###FIX
	else:
	    return 0
##        if self.isroomleftexit():
##	    self.setxyfromleft()	
##	    return 9
##	elif self.isroomrightexit():
##	    self.setxyfromright()	
##	    return 10
##	else:
	    return 0

    def removeobject(self, o):
        for i in (0,len(self.gameobjects)-1):
            if (self.gameobjects[i] and self.gameobjects[i] == o):
                print "PICKUP"
                self.gameobjects[i] = None

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from maproom import *
from knight import *
from mongbat import *
from maproom2 import *
from dungeonmasterkey import *
from gohma import *
from gohmaup import *
from gohmaright import *
from demon import *

class Maproom9(Maproom):
    "Room with a (big) map"
    def __init__(self,x,y):
        Maproom.__init__(self,x,y)
        self.background = pygame.image.load('./pics/room-bg9.bmp').convert()	#self.gameobjects.append(Dungeonmasterkey(50,50))
	self.gameobjects.append(Dungeonwall(0,0,300,40))
	self.gameobjects.append(Dungeonwall(0,260,300,40))
	self.gameobjects.append(Dungeonwall(0,0,40,300))
        self.gameobjects.append(Dungeonwall(260,0,40,300))
	### self.gameobjects.append(GohmaRight(50,50))
	self.gameobjects.append(Demon(50,50))

    def draw(self,screen):
        screen.blit(self.background, (0+self.relativex, 0+self.relativey))
        for i in self.gameobjects:
	    if i:
                i.draw(screen,self)
 
    def collide(self, player):
	for i in self.gameobjects:
	    if i != None:
		i.update(self)	
	for i in self.gameobjects:
            if i != None:
                id = i.collide(self,player)
                self.relativex = self.prevx
		self.relativey = self.prevy
		return id
	return 0

##    def pickup(self, player):
##        for o in self.gameobjects:
##            if (o and o.collidepickup(self, player)):
##                o.pickup(self)
##                return
##

    def exit(self, game):
        if self.isroomrightexit():
	    self.setxyfromright()	
	    return 8
	elif self.isroomdownexit():
	    self.setxyfromdown()	
	    return 10
	else:
	    return 0

    def removeobject(self, o):
        for i in (0,len(self.gameobjects)-1):
            if (self.gameobjects[i] and self.gameobjects[i] == o):
                print "PICKUP"
                self.gameobjects[i] = None

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from koboldwizard import *
from time import *

class MaproomBase:
    "Room with a (big) map"
    def __init__(self,x,y):
        ###Room.__init__(self)
        self.prevx = x
        self.prevy = y
        self.relativex = x
        self.relativey = y 
        self.background = pygame.image.load('./pics/blank.bmp').convert()
        self.direction = "east"

        self.locationtext = ""

        self.inventoryitem = None
        self.inventoryknife1 = 1
        self.inventorymasterkey = None
        self.inventorykey1 = None
        self.inventorykey2 = None
        self.inventoryrubysword = None
        self.inventorybow1 = None
        
    def draw(self,screen):
	##print "x=%d" % self.relativex 
        screen.blit(self.background, (0+self.relativex, 0+self.relativey))

    def undomove(self):
        # FIXME 
##        if self.direction == "north":
##            self.movedown()
##            #self.movedown()
##        elif self.direction == "south":
##            self.moveup()
##            #self.moveup()
        if self.direction == "west" or self.direction == "left":
            self.moveright()
            #self.moveright()
        elif self.direction == "east" or self.direction == "right":
            self.moveleft()
        elif self.direction == "north" or self.direction == "up":
            self.movedown()
        elif self.direction == "south" or self.direction == "down":
            self.moveup()
            #self.moveleft()

    def undomoveY(self):
        # FIXME 
##        if self.direction == "north":
##            self.movedown()
##            #self.movedown()
##        elif self.direction == "south":
##            self.moveup()
##            #self.moveup()
        if self.direction == "north" or self.direction == "up":
            self.relativey += 10
        elif self.direction == "south" or self.direction == "down":
            self.relativey -= 10
            #self.moveleft()

    def undomoveX(self):
        # FIXME 
        if self.direction == "west" or self.direction == "left":
            #self.direction = "east"
            self.relativex -= 10
            #self.moveright()
        elif self.direction == "east" or self.direction == "right":
            #self.direction = "west"
            self.relativex += 10
            #self.moveright()

    def moveup(self):
        #self.direction = "north"
        self.relativey = self.relativey - 10

    def movedown(self):
        #self.direction = "south"
        self.relativey = self.relativey + 10

    def moveleft(self):
        #self.direction = "west"
        self.relativex = self.relativex - 10

    def moveright(self):
        #self.direction = "east"
        self.relativex = self.relativex + 10

    def setxyup(self):
        self.x = -80 
        self.y = -80

    def setxydown(self):
        self.x = -80 
        self.y = -80

    def talkto(self):
        return None

    def collideXX(self,player):
        for i in self.gameobjects:
	    if i!= None:
	    	id = i.collideXX(self,player)
		if id:
			return id ## NOTE : returns collided entity (single)
##		self.relativex = self.prevx
##		self.relativey = self.prevy
        return None

    def collideX(self,player):
        for i in self.gameobjects:
	    if i!= None:
	    	id = i.collideX(self,player)
		if id:
			return id ## NOTE : returns collided entity (single)
##		self.relativex = self.prevx
##		self.relativey = self.prevy
        return None

    def collideY(self,player):
        for i in self.gameobjects:
	    if i!= None:
	    	id = i.collideY(self,player)
		if id:
			return id ## NOTE : returns collided entity (single)
##		self.relativex = self.prevx
##		self.relativey = self.prevy
        return None

    def collideXY(self,player):
        for i in self.gameobjects:
	    if i!= None:
	    	id = i.collideXY(self,player)
		if id:
			return id ## NOTE : returns collided entity (single)
##		self.relativex = self.prevx
##		self.relativey = self.prevy
        return None

    def pickup(self, player):
        for i in range(0,len(self.gameobjects)):
	    o = self.gameobjects[i]
            if o and o.collidepickup(self,player):
                id = o.pickup(player)
		self.gameobjects[i] = None
                return id# FIX 
        return 0



    def collidesword(self,player):
        for i in self.gameobjects:
	    if i!= None:
	    	c = i.collide(self,player)
		if c:
			return i ## NOTE : returns collided entity (single)
##		self.relativex = self.prevx
##		self.relativey = self.prevy
        return None


    def collidebow(self,player):
        for i in self.gameobjects:
	    if i!= None:
	    	c = i.collidebow(self,player)
		if c:
			return i ## NOTE : returns collided entity (single)
##		self.relativex = self.prevx
##		self.relativey = self.prevy
        return None

    def collideknife(self,player):
        for i in self.gameobjects:
	    if i!= None:
	    	c = i.collideknife(self,player)
		if c:
			return i ## NOTE : returns collided entity (single)
##		self.relativex = self.prevx
##		self.relativey = self.prevy
        return None

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from koboldwizard import *
from time import *
from maproom import *

# each wall has its own pic, for dithered and changed images
class MaproomEastDungeonWall:
    "Room with a (big) map"
    def __init__(self,x,y):
        self.x = x
        self.y = y
        self.wallimage = pygame.load.image('./pics/walldungeon1-60x48.bmp')
        
        
    def draw(self,screen):
	##print "x=%d" % self.relativex 
        screen.blit(self.wall, (0+self.relativex, 0+self.relativey))

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from koboldwizard import *
from time import *
from maproom import *

# each wall has its own pic, for dithered and changed images
class MaproomNorthDungeonWall:
    "Room with a (big) map"
    def __init__(self,x,y):
        self.x = x
        self.y = y
        self.w = 60
        self.h = 48
        self.wallimage = pygame.image.load('./pics/walldungeon1-60x48.bmp')
        
        
    def draw(self,screen,relativex,relativey):
	##print "x=%d" % self.relativex 
        screen.blit(self.wallimage, (self.x+relativex, self.y+relativey))

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from koboldwizard import *
from time import *
from maproom import *
from maproomdungeonnorthwall import *
from maproomdungeonsouthwall import *
from maproomdungeonwestwall import *
from maproomdungeoneastwall import *

class MaproomDungeon(MaproomBase):
    "Room with a (big) map"
    def __init__(self,x,y):
        MaproomBase.__init__(self,x,y)
        self.northwalls = []
        self.southwalls = []
        self.westwalls = []
        self.eastwalls= []
        self.gameobjects = []
        self.tileboxes = []
        self.pits = []
        self.ropes = []
        self.movingplatforms = []
        
    def addnorthwall(self, x,y):
        self.northwalls.append(MaproomNorthDungeonWall(x,y))

    def addsouthwall(self, x,y):
        self.southwalls.append(MaproomSouthDungeonWall(x,y))

    def addwestwall(self, x,y):
        self.westwalls.append(MaproomWestDungeonWall(x,y))

    def addeastwall(self, x,y):
        self.eastwalls.append(MaproomEastDungeonWall(x,y))
        
    def draw(self,screen):
	##print "x=%d" % self.relativex 
        screen.blit(self.background, (0+self.relativex, 0+self.relativey))
        for w in self.northwalls:
            w.draw(screen,self.relativex,self.relativey)



    def collidewithropes(self, player):	
	for i in self.ropes:
	    if i != None and i.collidewithrope(self, player):
		return 2
	return 0

      
# NOTE player can be enemy 
    def collide(self, player):	
	for i in self.gameobjects:
	    if i != None and i.collide(self, player):
		return 4 # 2 before, 1 kills game
	for i in self.northwalls:
	    if i != None and i.collide(self, player):
		return 2
	for i in self.southwalls:
	    if i != None and i.collide(self, player):
		return 2
	for i in self.westwalls:
	    if i != None and i.collide(self, player):
		return 2
	for i in self.eastwalls:
	    if i != None and i.collide(self, player):
		return 2
	for i in self.tileboxes:
		if i != None and i.collide(self,player):
	                # FIXME self.undomove()
			return 2 
	for i in self.pits:
		if i != None and i.collide(self,player):
			return 2
	return 0

    def collidewithenemy(self, enemy):
	for t in self.tileboxes:
		if t != None and t != enemy and t.collidewithenemy(self,enemy):
                    #FIXME1 enemy.undomove()
                    return 2 # 1 kills game
        return 0

      
    def collideboxeswithenemy(self, enemy):
        #FIXME1 do not collide enemies with themselves when overlapping etc.
	for t in self.gameobjects:   
                # FIXME t != enemy, do not collide with same object
                # FIXME1 do not collide with enemies when colliding only with boxes
		if t != None and t != enemy and t.collideboxes(self,enemy):
                    #enemy.undomove()                    
                    return t # 1 kills game
        return 0


    def fall(self, player):
        self.moveup()
        for i in self.gameobjects:
	    if i != None and i.fallcollide(self, player):
                self.movedown()
		return 2 # 1 kills game
        
        return 0

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from koboldwizard import *
from time import *
from maproom import *

# each wall has its own pic, for dithered and changed images
class MaproomSouthDungeonWall:
    "Room with a (big) map"
    def __init__(self,x,y):
        self.x = x
        self.y = y
        self.wallimage = pygame.load.image('./pics/walldungeon1-60x48.bmp')
        
        
    def draw(self,screen):
	##print "x=%d" % self.relativex 
        screen.blit(self.wall, (0+self.relativex, 0+self.relativey))

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from koboldwizard import *
from time import *
from maproom import *

# each wall has its own pic, for dithered and changed images
class MaproomDungeonWall:
    "Room with a (big) map"
    def __init__(self,x,y):
        self.x = x
        self.y = y
        self.wallimage = pygame.image.load('./pics/walldungeon1-60x48.bmp')
        
        
##    def draw(self,screen,self.relativex,self.relativey):
##	##print "x=%d" % self.relativex 
##        screen.blit(self.wallimage, (relativex+self.x, relativey+self.y))

    def collide(self, room, player):
	if (player.x > self.x+room.relativex  and 
	player.x < self.x+room.relativex+self.w and 
	player.y > self.y+room.relativey and 
	player.y < self.y+room.relativey + self.h):
	    print "collision in Dungeon Wall!"	
	    return 1 
	else:
	    return 0

    def collidepickup(self, room, player):
	if (player.x > self.x+room.relativex-self.w  and 
	player.x < self.x+room.relativex+self.w and 
	player.y > self.y+room.relativey-self.h and 
	player.y < self.y+room.relativey + self.h):
	    #print "collision!"	
	    return 1 
	else:
	    return 0 
    
    def collideobjectX(self, room):
	for i in room.gameobjects:
	    if i != None:	
	        if (self.x > i.x  and 
		    self.x < i.x+i.w):
	            return 1 
	return 0

    def collideobjectY(self, room):
	for i in room.gameobjects:
	    if i != None:	
	        if (self.y > i.y  and 
		    self.y < i.y+i.h):
	            return 1 
	return 0
 
    def collideobjectXY(self, room):
	for i in room.gameobjects:
	    if i:		
	        if (self.x > i.x  and 
	 	    self.x < i.x+i.w and 
	            self.y > i.y and 
	            self.y < i.y+i.h):
	            return 1 
	return 0 

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from koboldwizard import *
from time import *
from maproom import *

# each wall has its own pic, for dithered and changed images
class MaproomWestDungeonWall:
    "Room with a (big) map"
    def __init__(self,x,y):
        self.x = x
        self.y = y
        self.wallimage = pygame.load.image('./pics/walldungeon1-60x48.bmp')
        
        
    def draw(self,screen):
	##print "x=%d" % self.relativex 
        screen.blit(self.wall, (0+self.relativex, 0+self.relativey))

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from maproom import *
from knight import *
from blackknight import *
from demon import *
from bombman import *
from turtleflying import *
from ghost1 import *
from ghostwandering import *
from ghostcircling import *
from maproom2 import *
from dungeonmasterkey import *
from dungeonkey1 import *
from mithran import *
from innguardian import *

class Maproominn1_3(Maproom):
    "Room with a (big) map - third South of Knight's Castle, Towards Inn Grove"
    def __init__(self,x,y):
        Maproom.__init__(self,x,y)
        self.background = pygame.image.load('./pics/room-bginn1_3.bmp').convert()
        self.gameobjects.append(Tree2(10,20))
	self.gameobjects.append(Tree2(200,70))
	self.gameobjects.append(Tree2(400,10))
        self.guardian = InnGuardian(160,320)
        self.gameobjects.append(self.guardian)
	self.gameobjects.append(Dungeonwall(0,0,100,500))
	self.gameobjects.append(Dungeonwall(200,0,100,500))
	# Inn walls
	self.gameobjects.append(Dungeonwall(0,175,150,400))
	self.gameobjects.append(Dungeonwall(250,250,250,250))
        
    def draw(self,screen):
        screen.blit(self.background, (0+self.relativex, 0+self.relativey))
        for i in self.gameobjects:
	    if i:
                i.draw(screen,self)
 
    def collide(self, player):
	for i in self.gameobjects:
	    if i != None:
		i.update(self)	
	for i in self.gameobjects:
	    if i!= None:
	    	id = i.collide(self,player)
		self.relativex = self.prevx
		self.relativey = self.prevy
		return id
	return 0

    def pickup(self, player):###FIX for each room
        for o in self.gameobjects:
            if (o and o.collide(self, player)):##FIX o.colidepickup
                id = o.pickup(self)
                self.dungeonkey1 = 1
		return id
        return 0
    
    def exit(self, game):
        # FIX
	return 0

    def removeobject(self, o):
        for i in (0,len(self.gameobjects)-1):
            print "o=%s self.gameobjects[i]=%s i=%d" % (o,self.gameobjects[i],i)
            if self.gameobjects[i] == o:
                print "PICKUP or die"
                self.gameobjects[i] = None
		return 

    def collidesword(self,room,player):
        for i in self.gameobjects:
	    if i!= None:
	    	c = i.collide(room,player)
	    	print "i=%s" % i
		if c == 1:
                        print "collision with i=%s!" % i
			return i ## NOTE : returns collided entity (single)
		self.relativex = self.prevx
		self.relativey = self.prevy
	return None

    def isroomdownexit(self):
	if self.relativey < - 200:### and self.relativey < 20:
		return 1
	return 0
	
    def exit(self, game):
##        print "x=%d y=%d" % (self.relativex,self.relativey)
##        if self.isroomupexit():
##	    self.setxyfromup()	    
##	    return 1
	if self.isroomdownexit():
	    self.setxyfromdown()	    
	    return 1.4
	if self.isroomupexit():
	    self.setxyfromup()	    
	    return 1.2
##	#Trap door: elif self.isroomdownexit():
##	#    self.setxyfromdown()	
##	#    return 11
##	else:
	return 0

    def talkto(self):#FIXME needs font
            print "talk to in maproom 1_3"
            ## return self.koboldwiz
            self.guardian.talkcounter = 1
            return self.guardian

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from maproom import *
from knight import *
from blackknight import *
from demon import *
from bombman import *
from turtleflying import *
from ghost1 import *
from ghostwandering import *
from ghostcircling import *
from maproom2 import *
from dungeonmasterkey import *
from dungeonkey1 import *
from mithran import *
from innguardian2 import *

class Maproominn1_4(Maproom):
    "Room with a (big) map - Inside Inn"
    def __init__(self,x,y):
        Maproom.__init__(self,x,y)
        self.background = pygame.image.load('./pics/room-bginn1_4.bmp').convert()
##        self.gameobjects.append(Tree2(10,200))
##	self.gameobjects.append(Tree2(200,170))
##	self.gameobjects.append(Tree2(400,210))
	self.gameobjects.append(Dungeonwall(0,0,600,50))
	self.gameobjects.append(Dungeonwall(0,0,50,600))
	self.gameobjects.append(Dungeonwall(550,0,50,600))
	self.gameobjects.append(Dungeonwall(0,550,600,50))
	self.guardian = InnGuardian2(460,140)
        self.gameobjects.append(self.guardian)
	# Inn walls
	#self.gameobjects.append(Dungeonwall(0,300,500,100))
        
        
    def draw(self,screen):
        screen.blit(self.background, (0+self.relativex, 0+self.relativey))
        for i in self.gameobjects:
	    if i:
                i.draw(screen,self)
 
    def collide(self, player):
	for i in self.gameobjects:
	    if i != None:
		i.update(self)	
	for i in self.gameobjects:
	    if i!= None:
	    	id = i.collide(self,player)
		self.relativex = self.prevx
		self.relativey = self.prevy
		return id
	return 0

    def pickup(self, player):###FIX for each room
        for o in self.gameobjects:
            if (o and o.collide(self, player)):##FIX o.colidepickup
                id = o.pickup(self)
                self.dungeonkey1 = 1
		return id
        return 0
    
    def removeobject(self, o):
        for i in (0,len(self.gameobjects)-1):
            print "o=%s self.gameobjects[i]=%s i=%d" % (o,self.gameobjects[i],i)
            if self.gameobjects[i] == o:
                print "PICKUP or die"
                self.gameobjects[i] = None
		return 

    def collidesword(self,room,player):
        for i in self.gameobjects:
	    if i!= None:
	    	c = i.collide(room,player)
	    	print "i=%s" % i
		if c == 1:
                        print "collision with i=%s!" % i
			return i ## NOTE : returns collided entity (single)
		self.relativex = self.prevx
		self.relativey = self.prevy
	return None

    def setxyfromdoor(self):
        self.relativex = -150
        self.relativey = -250
    
    def isroomdoorexit(self):
	if self.relativex < -50 and self.relativex > -100 and self.relativey > -280 and self.relativey < -240:
            return 1
        return 0
    
    def exit(self, game):
        print "x=%d y=%d" % (self.relativex,self.relativey)
        if self.isroomupexit():
	    self.setxyfromup()	    
	    return 1.3
	elif self.isroomdoorexit():
            self.setxyfromdoor()
            return 1.5            
##	elif self.isroomdownexit():
##	    self.setxyfromdown()	    
##	    return 1.2
##	#Trap door: elif self.isroomdownexit():
##	#    self.setxyfromdown()	
##	#    return 11
##	else:
	return 0

    def talkto(self):#FIXME needs font
            print "talk to in maproom 1_3"
            ## return self.koboldwiz
            self.guardian.talkcounter = 1
            return self.guardian

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from maproom import *
from knight import *
from blackknight import *
from demon import *
from bombman import *
from turtleflying import *
from ghost1 import *
from ghostwandering import *
from ghostcircling import *
from maproom2 import *
from dungeonmasterkey import *
from dungeonkey1 import *
from mithran import *
from innguardian2 import *
from roadsigninn import *

from butterfly import *
from butterfly2 import *

class Maproominn1_4(Maproom):
    "Room with a (big) map - Inside Inn"
    def __init__(self,x,y):
        Maproom.__init__(self,x,y)
        self.background = pygame.image.load('./pics/room-bginn1_4.bmp').convert()
        # Inn walls
	self.gameobjects.append(Dungeonwall(200,0,200,100))
        # Rooms + Barracks
	self.gameobjects.append(Dungeonwall(200,250,300,100))
	# Trees etc.
        self.gameobjects.append(Tree2(10,200))
	self.gameobjects.append(Tree2(200,170))
	self.gameobjects.append(Tree2(100,410))
	self.gameobjects.append(Dungeonwall(0,0,600,50))
	self.gameobjects.append(Dungeonwall(0,0,50,600))
	self.gameobjects.append(Dungeonwall(550,0,50,600))
	self.gameobjects.append(Dungeonwall(0,550,600,50))
	self.guardian = InnGuardian2(300,140)
        self.gameobjects.append(self.guardian)

        self.gameobjects.append(RoadSignInn(200,100))
        
        self.gameobjects.append(Butterfly(100,100))
        self.gameobjects.append(Butterfly2(500,100))
        self.gameobjects.append(Butterfly2(300,400))
        
    def draw(self,screen):
        screen.blit(self.background, (0+self.relativex, 0+self.relativey))
        for i in self.gameobjects:
	    if i:
                i.draw(screen,self)
 
    def collide(self, player):
	for i in self.gameobjects:
	    if i != None:
		i.update(self)	
	for i in self.gameobjects:
	    if i!= None:
	    	id = i.collide(self,player)
		self.relativex = self.prevx
		self.relativey = self.prevy
		return id
	return 0

    def pickup(self, player):###FIX for each room
        for o in self.gameobjects:
            if (o and o.collide(self, player)):##FIX o.colidepickup
                id = o.pickup(self)
                self.dungeonkey1 = 1
		return id
        return 0
    
    def removeobject(self, o):
        for i in (0,len(self.gameobjects)-1):
            print "o=%s self.gameobjects[i]=%s i=%d" % (o,self.gameobjects[i],i)
            if self.gameobjects[i] == o:
                print "PICKUP or die"
                self.gameobjects[i] = None
		return 

    def collidesword(self,room,player):
        for i in self.gameobjects:
	    if i!= None:
	    	c = i.collide(room,player)
	    	print "i=%s" % i
		if c == 1:
                        print "collision with i=%s!" % i
			return i ## NOTE : returns collided entity (single)
		self.relativex = self.prevx
		self.relativey = self.prevy
	return None

    def setxyfromdoor(self):
        self.relativex = 0
        self.relativey = -100
    
    def isroomdoorexit(self):
	if self.relativex < -140 and self.relativex > -188 and self.relativey > 30 and self.relativey < 50:
            return 1
        return 0

    def setxyfromup(self):
        self.relativex = -60
        self.relativey = -110
    
    def isroomupexit(self):
	if self.relativex > 0 and self.relativex < 100 and self.relativey > 100:
            return 1
        return 0
    
    def exit(self, game):
        if self.isroomupexit():
	    self.setxyfromup()	    
	    return 1.3
	elif self.isroomdoorexit():
            self.setxyfromdoor()
            return 1.5            
	return 0

    def talkto(self):#FIXME needs font
            print "talk to in maproom 1_3"
            ## return self.koboldwiz
            self.guardian.talkcounter = 1
            return self.guardian

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from maproom import *
from knight import *
from blackknight import *
from demon import *
from bombman import *
from turtleflying import *
from ghost1 import *
from ghostwandering import *
from ghostcircling import *
from maproom2 import *
from dungeonmasterkey import *
from dungeonkey1 import *
from mithran import *
from innguardian3 import *
from inndoor import *

class Maproominn1_5(Maproom):
    "Room with a (big) map - Inside Inn"
    def __init__(self,x,y):
        Maproom.__init__(self,x,y)
        self.background = pygame.image.load('./pics/room-bginn1_5.bmp').convert()
        # Inn upper walls
	self.gameobjects.append(Dungeonwall(0,0,160,200))
	self.gameobjects.append(Dungeonwall(0,0,320,120))
	self.gameobjects.append(Dungeonwall(400,300,300,100))
	self.gameobjects.append(Dungeonwall(500,0,200,500))
        # Inn lower walls
        self.gameobjects.append(Dungeonwall(0,300,160,200))
        self.gameobjects.append(Dungeonwall(0,400,500,700))
        self.gameobjects.append(Dungeonwall(440,280,260,220))
        # Inn table
        self.gameobjects.append(Dungeonwall(220,180,160,220))
        # door
        self.gameobjects.append(InnDoor(320,25))
        # guardian
        self.guardian = InnGuardian3(460,90)
        self.gameobjects.append(self.guardian)
        
    def draw(self,screen):
        screen.blit(self.background, (0+self.relativex, 0+self.relativey))
        for i in self.gameobjects:
	    if i:
                i.draw(screen,self)
 
    def collide(self, player):
	for i in self.gameobjects:
	    if i != None:
		i.update(self)	
	for i in self.gameobjects:
	    if i!= None:
	    	id = i.collide(self,player)
		self.relativex = self.prevx
		self.relativey = self.prevy
		return id
	return 0

    def pickup(self, player):###FIX for each room
        for o in self.gameobjects:
            if (o and o.collide(self, player)):##FIX o.colidepickup
                id = o.pickup(self)
                self.dungeonkey1 = 1
		return id
        return 0
    
    def exit(self, game):
        # FIX
	return 0

    def removeobject(self, o):
        for i in (0,len(self.gameobjects)-1):
            print "o=%s self.gameobjects[i]=%s i=%d" % (o,self.gameobjects[i],i)
            if self.gameobjects[i] == o:
                print "PICKUP or die"
                self.gameobjects[i] = None
		return 

    def collidesword(self,room,player):
        for i in self.gameobjects:
	    if i!= None:
	    	c = i.collide(room,player)
	    	print "i=%s" % i
		if c == 1:
                        print "collision with i=%s!" % i
			return i ## NOTE : returns collided entity (single)
		self.relativex = self.prevx
		self.relativey = self.prevy
	return None

    def setxyfromdoor(self):
        self.relativex = -50
        self.relativey = -350
    
    def isroomdoorexit(self):
	if self.relativex < -140 and self.relativex > -190 and self.relativey > -250 and self.relativey < -230:
            return 1
        return 0

    def setxyfromdoor2(self):
        self.relativex = 0
        self.relativey = 0
    
    def isroomdoorexit2(self):
	if self.relativey > 100:
            return 1
        return 0
    
    def exit(self, game):
        print "x=%d y=%d" % (self.relativex,self.relativey)
	if self.isroomdoorexit():
            self.setxyfromdoor()
            return 1.4
        elif self.isroomdoorexit2():
            self.setxyfromdoor2()
            return 1.6  
##	elif self.isroomdownexit():
##	    self.setxyfromdown()	    
##	    return 1.2
##	#Trap door: elif self.isroomdownexit():
##	#    self.setxyfromdown()	
##	#    return 11
##	else:
	return 0

    def talkto(self):#FIXME needs font
            print "talk to in maproom 1_3"
            ## return self.koboldwiz
            self.guardian.talkcounter = 1
            return self.guardian

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from maproom import *
from knight import *
from blackknight import *
from demon import *
from bombman import *
from turtleflying import *
from ghost1 import *
from ghostwandering import *
from ghostcircling import *
from maproom2 import *
from dungeonmasterkey import *
from dungeonkey1 import *
from yuaninnkeeper import *
from rubysword import *

class Maproominn1_5(Maproom):
    "Room with a (big) map"
    def __init__(self,x,y):
        Maproom.__init__(self,x,y)
        self.background = pygame.image.load('./pics/room-bginn1_5.bmp').convert()
        ###	self.gameobjects.append(Bombman(100,50))
###	self.gameobjects.append(Bombman(200,100))
###	self.gameobjects.append(Bombman(100,150))
        self.yuan = YuanInnKeeper(110,120)
	self.gameobjects.append(self.yuan)
	self.gameobjects.append(Dungeonwall(0,0,300,100))
	self.gameobjects.append(Dungeonwall(200,0,100,300))
	self.gameobjects.append(Dungeonwall(0,0,100,300))
	self.gameobjects.append(Dungeonwall(0,200,300,100))
	self.gameobjects.append(RubySword(160,100))
	     
    def draw(self,screen):
        screen.blit(self.background, (0+self.relativex, 0+self.relativey))
        for i in self.gameobjects:
	    if i:
                i.draw(screen,self)
 
    def collide(self, player):
	for i in self.gameobjects:
	    if i != None:
		i.update(self)	
	for i in self.gameobjects:
	    if i!= None:
	    	id = i.collide(self,player)
		self.relativex = self.prevx
		self.relativey = self.prevy
		return id
	return 0

    def pickup(self, player):###FIX for each room
        for o in self.gameobjects:
            if (o and o.collide(self, player)):##FIX o.colidepickup
                id = o.pickup(self)
                self.dungeonkey1 = 1
		return id
        return 0
    
    def exit(self, game):
        # FIX
	return 0

    def removeobject(self, o):
        for i in (0,len(self.gameobjects)-1):
            print "o=%s self.gameobjects[i]=%s i=%d" % (o,self.gameobjects[i],i)
            if self.gameobjects[i] == o:
                print "PICKUP or die"
                self.gameobjects[i] = None
		return 

    def collidesword(self,room,player):
        for i in self.gameobjects:
	    if i!= None:
	    	c = i.collide(room,player)
	    	print "i=%s" % i
		if c == 1:
                        print "collision with i=%s!" % i
			return i ## NOTE : returns collided entity (single)
		self.relativex = self.prevx
		self.relativey = self.prevy
	return None

    def isroomhouseexit(self):
	if self.relativex  < 60 and self.relativex > -10 and self.relativey < -70 and self.relativey > - 130:### and self.relativey < 20:
		return 1
	return 0

    def setxyfromhouse(self):
        self.relativex = -600
	self.relativey = -500
	
	
    def exit(self, game):
        if self.isroomhouseexit():
	    self.setxyfromhouse()	    
	    return 1.4
	#Trap door: elif self.isroomdownexit():
	#    self.setxyfromdown()	
	#    return 11
	else:
	    return 0


    def talkto(self):#FIXME needs font
            print "talk to in maproom 6"
            ## return self.koboldwiz
            self.yuan.talkcounter = 1 # FIXME public var
            return self.yuan

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from maproom import *
from knight import *
from blackknight import *
from demon import *
from bombman import *
from turtleflying import *
from ghost1 import *
from ghostwandering import *
from ghostcircling import *
from maproom2 import *
from dungeonmasterkey import *
from dungeonkey1 import *
from mithran import *
from yuaninnkeeper import *

class Maproominn1_6(Maproom):
    "Room with a (big) map - Inside Inn 2nd room"
    def __init__(self,x,y):
        Maproom.__init__(self,x,y)
        self.background = pygame.image.load('./pics/room-bginn1_6.bmp').convert()
        # Inn upper walls
	self.gameobjects.append(Dungeonwall(0,0,400,100))
	self.gameobjects.append(Dungeonwall(0,0,20,400))
	self.gameobjects.append(Dungeonwall(400,0,20,400))
        self.yuan = YuanInnKeeper(100,130)
        self.gameobjects.append(self.yuan)
        
    def draw(self,screen):
        screen.blit(self.background, (0+self.relativex, 0+self.relativey))
        for i in self.gameobjects:
	    if i:
                i.draw(screen,self)
 
    def collide(self, player):
	for i in self.gameobjects:
	    if i != None:
		i.update(self)	
	for i in self.gameobjects:
	    if i!= None:
	    	id = i.collide(self,player)
		self.relativex = self.prevx
		self.relativey = self.prevy
		return id
	return 0

    def pickup(self, player):###FIX for each room
        for o in self.gameobjects:
            if (o and o.collide(self, player)):##FIX o.colidepickup
                id = o.pickup(self)
                self.dungeonkey1 = 1
		return id
        return 0
    
    def exit(self, game):
        # FIX
	return 0

    def removeobject(self, o):
        for i in (0,len(self.gameobjects)-1):
            print "o=%s self.gameobjects[i]=%s i=%d" % (o,self.gameobjects[i],i)
            if self.gameobjects[i] == o:
                print "PICKUP or die"
                self.gameobjects[i] = None
		return 

    def collidesword(self,room,player):
        for i in self.gameobjects:
	    if i!= None:
	    	c = i.collide(room,player)
	    	print "i=%s" % i
		if c == 1:
                        print "collision with i=%s!" % i
			return i ## NOTE : returns collided entity (single)
		self.relativex = self.prevx
		self.relativey = self.prevy
	return None

    def setxyfromdoor(self):
        self.relativex = -50
        self.relativey = -350
    
    def isroomdoorexit(self):
	if self.relativey < 0:
            return 1
        return 0
    
    def exit(self, game):
        print "x=%d y=%d" % (self.relativex,self.relativey)
	if self.isroomdoorexit():
            self.setxyfromdoor()
            return 1.5          
##	elif self.isroomdownexit():
##	    self.setxyfromdown()	    
##	    return 1.2
##	#Trap door: elif self.isroomdownexit():
##	#    self.setxyfromdown()	
##	#    return 11
##	else:
	return 0

    def talkto(self):#FIXME needs font
            print "talk to in maproom inn 1_6"
            ## return self.koboldwiz
            self.yuan.talkcounter = 1
            return self.yuan

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from maproom import *
from knight import *
from blackknight import *
from demon import *
from bombman import *
from turtleflying import *
from ghost1 import *
from ghostwandering import *
from ghostcircling import *
from maproom2 import *
from dungeonmasterkey import *
from dungeonkey1 import *
from mithran import *
from yuaninnkeeper import *

class Maproominn1_6(Maproom):
    "Room with a (big) map - Inside Inn 2nd room"
    def __init__(self,x,y):
        Maproom.__init__(self,x,y)
        self.background = pygame.image.load('./pics/room-bginn1_6.bmp').convert()
        # Inn upper walls
	self.gameobjects.append(Dungeonwall(0,0,400,100))
	self.gameobjects.append(Dungeonwall(0,0,20,400))
	self.gameobjects.append(Dungeonwall(400,0,20,400))
        self.yuan = YuanInnKeeper(100,130)
        self.gameobjects.append(self.yuan)
        
    def draw(self,screen):
        screen.blit(self.background, (0+self.relativex, 0+self.relativey))
        for i in self.gameobjects:
	    if i:
                i.draw(screen,self)
 
    def collide(self, player):
	for i in self.gameobjects:
	    if i != None:
		i.update(self)	
	for i in self.gameobjects:
	    if i!= None:
	    	id = i.collide(self,player)
		self.relativex = self.prevx
		self.relativey = self.prevy
		return id
	return 0

    def pickup(self, player):###FIX for each room
        for o in self.gameobjects:
            if (o and o.collide(self, player)):##FIX o.colidepickup
                id = o.pickup(self)
                self.dungeonkey1 = 1
		return id
        return 0
    
    def exit(self, game):
        # FIX
	return 0

    def removeobject(self, o):
        for i in (0,len(self.gameobjects)-1):
            print "o=%s self.gameobjects[i]=%s i=%d" % (o,self.gameobjects[i],i)
            if self.gameobjects[i] == o:
                print "PICKUP or die"
                self.gameobjects[i] = None
		return 

    def collidesword(self,room,player):
        for i in self.gameobjects:
	    if i!= None:
	    	c = i.collide(room,player)
	    	print "i=%s" % i
		if c == 1:
                        print "collision with i=%s!" % i
			return i ## NOTE : returns collided entity (single)
		self.relativex = self.prevx
		self.relativey = self.prevy
	return None

    def setxyfromdoor(self):
        self.relativex = -50
        self.relativey = -350
    
    def isroomdoorexit(self):
	if self.relativey < 0:
            return 1
        return 0
    
    def exit(self, game):
        print "x=%d y=%d" % (self.relativex,self.relativey)
	if self.isroomdoorexit():
            self.setxyfromdoor()
            return 1.5          
##	elif self.isroomdownexit():
##	    self.setxyfromdown()	    
##	    return 1.2
##	#Trap door: elif self.isroomdownexit():
##	#    self.setxyfromdown()	
##	#    return 11
##	else:
	return 0

    def talkto(self):#FIXME needs font
            print "talk to in maproom inn 1_6"
            ## return self.koboldwiz
            self.yuan.talkcounter = 1
            return self.yuan

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from koboldwizard import *
from time import *
from maproombase import *

class Maproom(MaproomBase):
    "Room with a (big) map"
    def __init__(self,x,y):
        MaproomBase.__init__(self,x,y)
        self.gameobjects = []
        ### NOTE all items which can only pickup once (see maproomXXX.py)
        self.dungeonkey1 = 0
        self.dungeonkey2 = 0
        self.masterkey = 0

        
    def draw(self,screen):
	##print "x=%d" % self.relativex 
        screen.blit(self.background, (0+self.relativex, 0+self.relativey))

    def pickup(self, player):
        return 0

    def undomove(self):
        if self.direction == "north":
            self.movedown()
            self.movedown()
        elif self.direction == "south":
            self.moveup()
            self.moveup()
        elif self.direction == "west":
            self.moveright()
            self.moveright()
        elif self.direction == "east":
            self.moveleft()
            self.moveleft()
 
    def moveup(self):
        self.direction = "north"
	self.prevx = self.relativex
	self.prevy = self.relativey + 10
        self.relativey = self.relativey - 10

    def movedown(self):
        self.direction = "south"
	self.prevx = self.relativex
	self.prevy = self.relativey - 10
        self.relativey = self.relativey + 10

    def moveleft(self):
        self.direction = "west"
	self.prevx = self.relativex + 10
	self.prevy = self.relativey
        self.relativex = self.relativex - 10

    def moveright(self):
        self.direction = "east"
	self.prevx = self.relativex - 10
	self.prevy = self.relativey
        self.relativex = self.relativex + 10

        
    def setxyfromleft(self):
        self.relativex = 0 
        self.relativey = 100

    def isroomleftexit(self):
	if self.relativex > 100 and self.relativey > -10:#FIX and self.relativey < -10 - 48:
		return 1
	return 0

    def setxyfromright(self):
        self.relativex = 100 
        self.relativey = 0

    def isroomrightexit(self):
	if self.relativex < -110 and self.relativey > -10:
		return 1
	return 0

    def setxyfromup(self):
        self.relativex = 0 
        self.relativey = -100

    def isroomupexit(self):
	if self.relativex >= 0 and self.relativey > 100 and self.relativey < 200:
		return 1
	return 0

    def setxyfromdown(self):
        self.relativex = 0 
        self.relativey = -100

    def isroomdownexit(self):
	if self.relativex  >= 0 and self.relativex <= 80 and self.relativey < -80:### and self.relativey < 20:
		return 1
	return 0

    def removeobject(self, o):
        for i in self.gameobjects:
	    if i!= None:
                if i == o:
                    i = None ###FIXME2

    def talkto(self):
        return None

    def collidesword(self,room,player):
        for i in self.gameobjects:
	    if i!= None:
	    	id = i.collide(room,player)
                ##self.relativex = self.prevx
		##self.relativey = self.prevy
		return i ## NOTE : returns collided entity (single)
	return None

    def hitwithsword(self, o):
        hitp = o.hit()
        if hitp < 0:
            self.removeobject(o)

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *

class Heart:
	def __init__(self):
        	self.image = pygame.image.load('./pics/heart.bmp').convert()
        	self.image.set_colorkey((0,0,0))
        	#self.imagemax = pygame.image.load('./pics/life1.bmp').convert()
        	#self.imagemax.set_colorkey((0,0,0))
		

class Meter:
    "life or mana meter"
    def __init__(self):
	self.max = 50 
	self.index = 50
	self.hearts = []
	for i in range(0,3):
		self.hearts.append(Heart())
 
    def draw(self,screen):
	# KLUDGY
	j = 0
	for i in range(0,self.index/10):
        	screen.blit(self.hearts[0].image, (500+j*12, 26))
		j += 1

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from time import *

class Mithran2(Gameobject):
    "BlackKnight"
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 48
        self.h = 48 
	self.stimlibdown = Stateimagelibrary()	
	self.stimlibup = Stateimagelibrary()	
        image = pygame.image.load('./pics/mithran1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)	
        image = pygame.image.load('./pics/mithran1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/mithran1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/mithran1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)

	image = pygame.image.load('./pics/mithran2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)	
        image = pygame.image.load('./pics/mithran2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/mithran2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/mithran2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)

        image = pygame.image.load('./pics/mithran3-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)	
        image = pygame.image.load('./pics/mithran3-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/mithran3-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/mithran3-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)

        image = pygame.image.load('./pics/mithran2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)	
        image = pygame.image.load('./pics/mithran2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/mithran2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/mithran2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)

        image = pygame.image.load('./pics/mithranup1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/mithranup1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/mithranup1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/mithranup1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)

	image = pygame.image.load('./pics/mithranup2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/mithranup2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/mithranup2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/mithranup2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)

	image = pygame.image.load('./pics/mithranup3-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/mithranup3-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/mithranup3-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/mithranup3-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
        	
        image = pygame.image.load('./pics/mithranup2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/mithranup2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/mithranup2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/mithranup2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)

	self.talkcounter = 0
	self.direction = "down"

    def draw(self, screen, room):
	if (self.direction == "down"):
            self.stimlibdown.draw(screen, self.x+room.relativex,self.y+room.relativey)
	elif (self.direction == "up"):
            self.stimlibup.draw(screen, self.x+room.relativex,self.y+room.relativey)
	    
	     
    def update(self,room):
        sleep(.04) # FIX mithran sleep
	
	if (not self.collideobjectY(room)): 
	    if (self.direction == "down"):
	        self.y -=2
	        self.direction = "up" 
	    elif (self.direction == "up"):
	        self.y +=2
	        self.direction = "down"

	if (self.direction == "up"):
	        self.y -=1 
	elif (self.direction == "down"):
	        self.y +=1

    def collide(self, room, player):
        
	if (player.x > self.x+room.relativex  and 
	player.x < self.x+room.relativex+self.w and 
	player.y > self.y+room.relativey and 
	player.y < self.y+room.relativey + self.h):
	    print "collision with Mithran!"
	    return 2 
	else:
	    return 0 ## for game self.talker

		 
    def talk(self, screen,font):
        if self.talkcounter == 0:
            return
        
        if self.talkcounter > 2:
                self.talkcounter = 0
                return 
        talkover = 0
        while talkover == 0:
            pygame.display.update()
            if self.talkcounter == 1:
                screen.blit(font.render("Welcome.", 8, (255,255,255)), (10,100))
            elif self.talkcounter == 2:
                screen.blit(font.render("Anything is good.", 8, (255,255,255)), (10,100))
            for event in pygame.event.get():
                if event.type == QUIT:
                    return
                elif event.type == KEYDOWN:
                    if event.key == K_z:
                        talkover = 1
                        self.talkcounter += 1
                

# Copyright (C) Johan Ceuppens 2010 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *

class Mithranhouse(Gameobject):
    "Mithran's house"
    def __init__(self, xx,yy,ww,hh):
        Gameobject.__init__(self,xx,yy)
        self.w = ww
        self.h = hh 
        self.image = pygame.image.load('./pics/mithranhouse1.1-200x200.bmp').convert()
        self.image.set_colorkey((0,0,0)) 

    def collide(self, room, player):
	if (player.x > self.x+room.relativex  and 
	player.x < self.x+room.relativex+self.w and 
	player.y > self.y+room.relativey and 
	player.y < self.y+room.relativey + self.h):
	    print "collision in box!"	
	    return 2 
	else:
	    return 0

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from time import *

class Mithran(Gameobject):
    "BlackKnight"
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 48
        self.h = 48 
	self.stimlibdown = Stateimagelibrary()	
	self.stimlibup = Stateimagelibrary()	
        image = pygame.image.load('./pics/mithran1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)	
        image = pygame.image.load('./pics/mithran1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/mithran1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/mithran1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)

	image = pygame.image.load('./pics/mithran2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)	
        image = pygame.image.load('./pics/mithran2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/mithran2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/mithran2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)

        image = pygame.image.load('./pics/mithran3-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)	
        image = pygame.image.load('./pics/mithran3-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/mithran3-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/mithran3-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)

        image = pygame.image.load('./pics/mithran2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)	
        image = pygame.image.load('./pics/mithran2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/mithran2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/mithran2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)

        image = pygame.image.load('./pics/mithranup1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/mithranup1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/mithranup1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/mithranup1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)

	image = pygame.image.load('./pics/mithranup2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/mithranup2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/mithranup2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/mithranup2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)

	image = pygame.image.load('./pics/mithranup3-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/mithranup3-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/mithranup3-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/mithranup3-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
        	
        image = pygame.image.load('./pics/mithranup2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/mithranup2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/mithranup2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/mithranup2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)

	self.talkcounter = 0
	self.direction = "down"

    def draw(self, screen, room):
	if (self.direction == "down"):
            self.stimlibdown.draw(screen, self.x+room.relativex,self.y+room.relativey)
	elif (self.direction == "up"):
            self.stimlibup.draw(screen, self.x+room.relativex,self.y+room.relativey)
	    
	     
    def update(self,room):
        sleep(.04) # FIX mithran sleep
	
	if (not self.collideobjectY(room)): 
	    if (self.direction == "down"):
	        self.y -=2
	        self.direction = "up" 
	    elif (self.direction == "up"):
	        self.y +=2
	        self.direction = "down"

	if (self.direction == "up"):
	        self.y -=1 
	elif (self.direction == "down"):
	        self.y +=1

    def collide(self, room, player):
        
	if (player.x > self.x+room.relativex  and 
	player.x < self.x+room.relativex+self.w and 
	player.y > self.y+room.relativey and 
	player.y < self.y+room.relativey + self.h):
	    print "collision with Mithran!"
	    return 2 
	else:
	    return 0 ## for game self.talker

		 
    def talk(self, screen,font):
        if self.talkcounter == 0:
            return
        
        if self.talkcounter > 2:
                self.talkcounter = 0
                return 
        talkover = 0
        while talkover == 0:
            pygame.display.update()
            if self.talkcounter == 1:
                screen.blit(font.render("I am Mithran.", 8, (255,255,255)), (10,100))
            elif self.talkcounter == 2:
                screen.blit(font.render("I live further north of here.", 8, (255,255,255)), (10,100))
            for event in pygame.event.get():
                if event.type == QUIT:
                    return
                elif event.type == KEYDOWN:
                    if event.key == K_z:
                        talkover = 1
                        self.talkcounter += 1
                

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random

class Mongbat(Gameobject):
    ""
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 64
        self.h = 64 
	self.stimlibleft = Stateimagelibrary()	
	self.stimlibright = Stateimagelibrary()	
        image = pygame.image.load('./pics/mongbat1-24x24.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/mongbat1-24x24.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
	self.direction = "left"

    def draw(self, screen, room):
	if (self.direction == "left"):
            self.stimlibleft.draw(screen, self.x+room.relativex,self.y+room.relativey)
	elif (self.direction == "right"):
            self.stimlibright.draw(screen, self.x+room.relativex,self.y+room.relativey)
	    
	     
    def update(self,room):
##        self.x-=1
##	if (random.randint(0,100) == 0 and self.direction == "left"):
##	   self.direction = "right"
##	elif (random.randint(0,100) == 0 and self.direction == "right"):
##	   self.direction = "left"
##
	if (not self.collideobjectX(room)): 
	    if (self.direction == "left"):
	        self.x +=2
	        self.direction = "right" 
	    elif (self.direction == "right"):
	        self.x -=2
	        self.direction = "left"


	if (self.direction == "left"):
	        self.x -=1 
	elif (self.direction == "right"):
	        self.x +=1

    def collide(self, room, player):
	if (player.x > self.x+room.relativex  and 
	player.x < self.x+room.relativex+self.w and 
	player.y > self.y+room.relativey and 
	player.y < self.y+room.relativey + self.h):
	    print "collision with Dark Knight!"
	    if player.hit():
		return 1 
	    else:
	    	return 2 
	else:
	    return 0

		 

# Copyright (C) Johan Ceuppens 2010 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *

class Movingplatform2(Gameobject):
    "Game object"
    def __init__(self, xx,yy,ww,hh,beginy,endy):
	self.x = xx
        self.y = beginy+10
        self.w = ww#100
        self.h = hh#22
        self.plx = beginy
        self.plx2 = endy
        ## dungeon statue as default picture
        ## self.image = pygame.image.load('./pics/dungeon-statue1-36x36.bmp').convert()
        self.image = pygame.image.load('./pics/movingplatform1-100x22.bmp').convert()
        self.image.set_colorkey((0,0,0)) 
        self.hitpoints = 100000000
        # NOTE : decrease 1 hitpoint with default sword
        self.direction = "down"

    def update(self,room,player):
        1
      
            
    def draw(self, screen, room, player):
        if self.direction == "down":
            self.y += 5
            if self.collidewithplatform(room,player):
                #player.y -= 10
                room.relativey += 10
                room.relativey -= 5
        elif self.direction == "up":     
            self.y -= 5
            if self.collidewithplatform(room,player):
                #player.y -= 10
                room.relativey += 10
                room.relativey += 5

        if self.y < self.plx:
            self.direction = "down"
            self.y += 5
        elif self.y > self.plx2:
            self.direction = "up"
            self.y -= 5
        screen.blit(self.image,(self.x+room.relativex,self.y+room.relativey))
	    
        
    def collidewithplatform(self, room, player):
        #print 'rope x=%d y=%d player x=%d y=%d' % (self.x,self.y,player.x-room.relativex,player.y-room.relativey)
	if (player.x-room.relativex > self.x and 
	player.x-room.relativex < self.x+self.w and 
	player.y-room.relativey > self.y-self.h and
	player.y-room.relativey < self.y):
	    #print "collision with Moving Platform!"
	    return 1 
	else:
	    return 0
    
   

# Copyright (C) Johan Ceuppens 2010 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *

class Movingplatform(Gameobject):
    "Game object"
    def __init__(self, xx,yy,ww,hh,beginx,endx):
	self.x = beginx+10
        self.y = yy 
        self.w = ww#100
        self.h = hh#22
        self.plx = beginx
        self.plx2 = endx
        ## dungeon statue as default picture
        ## self.image = pygame.image.load('./pics/dungeon-statue1-36x36.bmp').convert()
        self.image = pygame.image.load('./pics/movingplatform1-100x22.bmp').convert()
        self.image.set_colorkey((0,0,0)) 
        self.hitpoints = 100000000
        # NOTE : decrease 1 hitpoint with default sword
        self.direction = "right"

    def update(self,room,player):
        1
      
            
    def draw(self, screen, room, player):
        if self.direction == "right":
            self.x += 5
            if self.collidewithplatform(room,player):
                #player.y -= 10
                room.relativey += 10
                room.relativex -= 5
        elif self.direction == "left":     
            self.x -= 5
            if self.collidewithplatform(room,player):
                #player.y -= 10
                room.relativey += 10
                room.relativex += 5

        if self.x < self.plx:
            self.direction = "right"
            self.x += 5
        elif self.x > self.plx2:
            self.direction = "left"
            self.x -= 5
        screen.blit(self.image,(self.x+room.relativex,self.y+room.relativey))
	    
        
    def collidewithplatform(self, room, player):
        #print 'rope x=%d y=%d player x=%d y=%d' % (self.x,self.y,player.x-room.relativex,player.y-room.relativey)
	if (player.x-room.relativex > self.x and 
	player.x-room.relativex < self.x+self.w and 
	player.y-room.relativey > self.y-self.h and
	player.y-room.relativey < self.y):
	    #print "collision with Moving Platform!"
	    return 1 
	else:
	    return 0
    
    def update(self,room,player):
	1

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from stateimagelibrary import *
from playerbase import *

class PlayerAbeilleFighter(PlayerBase):
    "player Fighter"
    def __init__(self,heartmeter):
        PlayerBase.__init__(self,heartmeter)

        self.stimlib = Stateimagelibrary()	
        image = pygame.image.load('./pics/playerabeillefighter1-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/playerabeillefighter2-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/playerabeillefighter3-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/playerabeillefighter2-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/playerabeillefighter1-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/playerabeillefighter2-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/playerabeillefighter3-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlib.addpicture(image)	

        self.stimlibfight = Stateimagelibrary()	
        image = pygame.image.load('./pics/playerabeillefighterfight1-48x48.bmp').convert()
        image.set_colorkey((0,0,255))
        self.stimlibfight.addpicture(image)
        image = pygame.image.load('./pics/playerabeillefighterfight1-48x48.bmp').convert()
        image.set_colorkey((0,0,255))
        self.stimlibfight.addpicture(image)
        image = pygame.image.load('./pics/playerabeillefighterfight2-48x48.bmp').convert()
        image.set_colorkey((0,0,255))
        self.stimlibfight.addpicture(image)
        image = pygame.image.load('./pics/playerabeillefighterfight2-48x48.bmp').convert()
        image.set_colorkey((0,0,255))
        self.stimlibfight.addpicture(image)
        image = pygame.image.load('./pics/playerabeillefighterfight3-48x48.bmp').convert()
        image.set_colorkey((0,0,255))
        self.stimlibfight.addpicture(image)
        image = pygame.image.load('./pics/playerabeillefighterfight3-48x48.bmp').convert()
        image.set_colorkey((0,0,255))
        self.stimlibfight.addpicture(image)

    def draw(self, screen):
        # NOTE
        if self.fightcounter > 0:
            self.fightcounter += 1
            if self.fightcounter > 10:
                self.fightcounter = 0
            self.stimlibfight.draw(screen,self.x,self.y)
            return
        self.stimlib.draw(screen, self.x,self.y)

    def drawstatic(self,screen):
        self.draw(screen)
        
    def askclass(self):
        return "Fighter"

    def askrace(self):
        return "Abeille"

    def askpicture(self):
        return './pics/taskbar-PC-abeillefighter.bmp'

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from stateimagelibrary import *
from playerbase import *
from rng import *
from broadsword import *
from rubysword import *

class PlayerArchDwarf(PlayerBase):
    "Player Master Dwarf"
    def __init__(self,heartmeter):
        PlayerBase.__init__(self,PlayerBase.DROW,PlayerBase.MAGICUSER,heartmeter)
        
        self.stimlib = Stateimagelibrary()	
        image = pygame.image.load('./pics/player1-72x72.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
	

        self.stimlibfight = Stateimagelibrary()	
        image = pygame.image.load('./pics/playerfight1-72x72.bmp').convert()
        image.set_colorkey((0,0,0))
        self.stimlibfight.addpicture(image)

        self.stimlibclimbing = Stateimagelibrary()	
        image = pygame.image.load('./pics/player-climbing-72x72.bmp').convert()
        image.set_colorkey((0,0,255))
        self.stimlibclimbing.addpicture(image)

        self.hitpoints = 50
       	self.sword = BroadSword(0,0)

        self.jumpcounter = 0
 
    def askclass(self):
        return "Assassin"

    def askrace(self):
        return "Drow"

    def askpicture(self):
        return './pics/taskbar-PC-drowmage.bmp'

    def collidewithenemyweapon(self,room,o):
        if o.collide(room,self):
		return self ## NOTE : returns collided entity (single)
		
	return None

    def hitwithenemyweapon(self,damage):
	if damage > 0:
		print 'player is hit!'
        self.hitpoints -= damage

    def pickup(self,room):
        n = room.pickup(self)
	return n

    def fight(self,room):
        self.fightcounter = 1
        o = room.collidesword(self)
        if o:
            o.hitwithweapon(self.sword.roll())

    def jump(self, room):
        self.jumpcounter = 20
        self.direction = 'north'

    def update(self,room):
       if self.jumpcounter > 0 and self.jumpcounter < 200:
            room.relativey += 20
            self.jumpcounter += 15
       else:   
            self.jumpcounter = 0
            
    def setrubysword(self):
	self.sword = RubySword(0,0)

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from stateimagelibrary import *
from playerkatta import *
from playerfighter import *
from playermagicuser import *
from playerelf import *
from playerdrow import *

class PlayerBase:
    def __init__(self):
        1

class PlayerBase(PlayerBase,PlayerBase):
    "Player"

    PlayerBase.FIGHTER,PlayerBase.MAGICUSER = xrange(2)#,PlayerBase.MAGICUSER,PlayerBase.THIEF = xrange(3)
    PlayerBase.KATTA,PlayerBase.DROW = xrange(2)#,PlayerBase.HUMAN,PlayerBase.DROW = xrange(3)
    
    def __init__(self,PLAYERRACE,PLAYERCLASS,heartmeter):
        classByType = {
                #PlayerBase.HUMAN : PlayerHuman,
                PlayerBase.KATTA : PlayerKatta,
                #PlayerBase.ELF : PlayerElf,
                PlayerBase.DROW : PlayerDrow,
        }
        classByType2 = {
                PlayerBase.FIGHTER : PlayerFighter,
                PlayerBase.MAGICUSER : PlayerMagicUser,
                #Player.THIEF : PlayerThief,
        }
	self.heartmeter = heartmeter

        self.direction = "right"

        self.x = 280 
        self.y = 300 
        self.w = 72
        self.h = 72
##	self.stimlib = Stateimagelibrary()	
##        image = pygame.image.load('./pics/player1-30x30.bmp').convert()
##        image.set_colorkey((0,0,0)) 
##	self.stimlib.addpicture(image)	
##        image = pygame.image.load('./pics/player2-30x30.bmp').convert()
##        image.set_colorkey((0,0,0)) 
##	self.stimlib.addpicture(image)	
##        image = pygame.image.load('./pics/player3-30x30.bmp').convert()
##        image.set_colorkey((0,0,0)) 
##	self.stimlib.addpicture(image)	
##        image = pygame.image.load('./pics/player2-30x30.bmp').convert()
##        image.set_colorkey((0,0,0)) 
##	self.stimlib.addpicture(image)	
##        image = pygame.image.load('./pics/player1-30x30.bmp').convert()
##        image.set_colorkey((0,0,0)) 
##	self.stimlib.addpicture(image)	
##        image = pygame.image.load('./pics/player2-30x30.bmp').convert()
##        image.set_colorkey((0,0,0)) 
##	self.stimlib.addpicture(image)	
##        image = pygame.image.load('./pics/player3-30x30.bmp').convert()
##        image.set_colorkey((0,0,0)) 
##	self.stimlib.addpicture(image)	
##
##        self.stimlibfight = Stateimagelibrary()	
##        image = pygame.image.load('./pics/playerfight1-30x30.bmp').convert()
##        image.set_colorkey((0,0,0))
##        self.stimlibfight.addpicture(image)
##        image = pygame.image.load('./pics/playerfight1-30x30.bmp').convert()
##        image.set_colorkey((0,0,0))
##        self.stimlibfight.addpicture(image)
##        image = pygame.image.load('./pics/playerfight2-30x30.bmp').convert()
##        image.set_colorkey((0,0,0))
##        self.stimlibfight.addpicture(image)
##        image = pygame.image.load('./pics/playerfight2-30x30.bmp').convert()
##        image.set_colorkey((0,0,0))
##        self.stimlibfight.addpicture(image)
##        image = pygame.image.load('./pics/playerfight3-30x30.bmp').convert()
##        image.set_colorkey((0,0,0))
##        self.stimlibfight.addpicture(image)
##        image = pygame.image.load('./pics/playerfight3-30x30.bmp').convert()
##        image.set_colorkey((0,0,0))
##        self.stimlibfight.addpicture(image)

        self.fightcounter = 0

        classByType[PLAYERRACE](heartmeter)
        classByType2[PLAYERCLASS](heartmeter)

    def drawstatic(self, screen):
        # NOTE
        if self.fightcounter > 0:
            self.fightcounter += 1
            if self.fightcounter > 10:
                self.fightcounter = 0
            self.stimlibfight.draw(screen,self.x,self.y)
            return
        if self.direction == "right":
            self.stimlibright.drawstatic(screen,self.x,self.y,0)
        if self.direction == "left":
            self.stimlibleft.drawstatic(screen,self.x,self.y,0)

    def drawclimbing(self, screen):
	self.stimlibclimbing.draw(screen,self.x,self.y)

    def drawduck(self, screen):
	self.stimlibduck.draw(screen,self.x,self.y)
	
    def draw(self, screen):
        # NOTE
        if self.fightcounter > 0:
            self.fightcounter += 1
            if self.fightcounter > 10:
                self.fightcounter = 0
            self.stimlibfight.draw(screen,self.x,self.y)#FIXME
            return
        
        if self.direction == "right":
            self.stimlibright.draw(screen,self.x,self.y)
        if self.direction == "left":
            self.stimlibleft.draw(screen,self.x,self.y)

    def fight(self,room):
        self.fightcounter = 1
##        self.x -= 30
##        self.y -= 30
##        self.w += 30
##        self.h += 30
        
        o = room.collidesword(room,self)
        
        if o:
            print 'hit!'
            room.hitwithsword(o)
##        self.x += 30
##        self.y += 30
##        self.w -= 30
##        self.h -= 30
##

        
    def hit(self):
	self.heartmeter.index -= 1 
	if self.heartmeter.index <= 0:
		return 0 #FIXME1 FIX for gameover when collision with enemies 
	else:
		return 0	

    def askclass(self):
        return "Fighter"

    def askrace(self):
        return "Human"

    def askpicture(self):
        return './pics/taskbar-PC.bmp'


# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from stateimagelibrary import *
#from playerbase import *

class PlayerDrow:
    "Player Fighter"
    def __init__(self,heartmeter):
        1#PlayerBase.__init__(self,heartmeter)


# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from stateimagelibrary import *
from playerbase import *

class PlayerElfFighter(PlayerBase):
    "playerelffighter Fighter"
    def __init__(self,heartmeter):
        PlayerBase.__init__(self,heartmeter)

        self.stimlib = Stateimagelibrary()	
        image = pygame.image.load('./pics/playerelffighter1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/playerelffighter2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/playerelffighter3-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/playerelffighter2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/playerelffighter1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/playerelffighter2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/playerelffighter3-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)	

        self.stimlibfight = Stateimagelibrary()	
        image = pygame.image.load('./pics/playerelffighterfight1-48x48.bmp').convert()
        image.set_colorkey((0,0,0))
        self.stimlibfight.addpicture(image)
        image = pygame.image.load('./pics/playerelffighterfight1-48x48.bmp').convert()
        image.set_colorkey((0,0,0))
        self.stimlibfight.addpicture(image)
        image = pygame.image.load('./pics/playerelffighterfight2-48x48.bmp').convert()
        image.set_colorkey((0,0,0))
        self.stimlibfight.addpicture(image)
        image = pygame.image.load('./pics/playerelffighterfight2-48x48.bmp').convert()
        image.set_colorkey((0,0,0))
        self.stimlibfight.addpicture(image)
        image = pygame.image.load('./pics/playerelffighterfight3-48x48.bmp').convert()
        image.set_colorkey((0,0,0))
        self.stimlibfight.addpicture(image)
        image = pygame.image.load('./pics/playerelffighterfight3-48x48.bmp').convert()
        image.set_colorkey((0,0,0))
        self.stimlibfight.addpicture(image)


    def askclass(self):
        return "Fighter"

    def askrace(self):
        return "Elf"

    def askpicture(self):
        return './pics/taskbar-PC-elffighter.bmp'

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from stateimagelibrary import *
from playerbase import *

class PlayerElf:
    "Player Fighter"
    def __init__(self,heartmeter):
        1#PlayerBase.__init__(self,heartmeter)


# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from stateimagelibrary import *
from playerbase import *

class PlayerElfThief(PlayerBase):
    "Player Thief"
    def __init__(self,heartmeter):
        PlayerBase.__init__(self,heartmeter)

        self.stimlib = Stateimagelibrary()	
        image = pygame.image.load('./pics/playerelfthief1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/playerelfthief2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/playerelfthief3-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/playerelfthief2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/playerelfthief1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/playerelfthief2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/playerelfthief3-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)	

        self.stimlibfight = Stateimagelibrary()	
        image = pygame.image.load('./pics/playerelfthieffight1-48x48.bmp').convert()
        image.set_colorkey((0,0,0))
        self.stimlibfight.addpicture(image)
        image = pygame.image.load('./pics/playerelfthieffight1-48x48.bmp').convert()
        image.set_colorkey((0,0,0))
        self.stimlibfight.addpicture(image)
        image = pygame.image.load('./pics/playerelfthieffight2-48x48.bmp').convert()
        image.set_colorkey((0,0,0))
        self.stimlibfight.addpicture(image)
        image = pygame.image.load('./pics/playerelfthieffight2-48x48.bmp').convert()
        image.set_colorkey((0,0,0))
        self.stimlibfight.addpicture(image)
        image = pygame.image.load('./pics/playerelfthieffight3-48x48.bmp').convert()
        image.set_colorkey((0,0,0))
        self.stimlibfight.addpicture(image)
        image = pygame.image.load('./pics/playerelfthieffight3-48x48.bmp').convert()
        image.set_colorkey((0,0,0))
        self.stimlibfight.addpicture(image)


    def askclass(self):
        return "Thief"

    def askrace(self):
        return "Elven"

    def askpicture(self):
        return './pics/taskbar-PC-elfthief.bmp'

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from stateimagelibrary import *
#from playerbase import *

class PlayerFighter:
    "Player Fighter"
    def __init__(self,heartmeter):
        1#PlayerBase.__init__(self,heartmeter)


# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from stateimagelibrary import *
from playerbase import *

class PlayerGnollFighter(PlayerBase):
    "Player Fighter"
    def __init__(self,heartmeter):
        PlayerBase.__init__(self,heartmeter)

        self.stimlib = Stateimagelibrary()	
        image = pygame.image.load('./pics/playergnollfighter1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/playergnollfighter2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/playergnollfighter3-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/playergnollfighter2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/playergnollfighter1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/playergnollfighter2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/playergnollfighter3-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)	

        self.stimlibfight = Stateimagelibrary()	
        image = pygame.image.load('./pics/playergnollfighterfight1-48x48.bmp').convert()
        image.set_colorkey((0,0,0))
        self.stimlibfight.addpicture(image)
        image = pygame.image.load('./pics/playergnollfighterfight1-48x48.bmp').convert()
        image.set_colorkey((0,0,0))
        self.stimlibfight.addpicture(image)
        image = pygame.image.load('./pics/playergnollfighterfight2-48x48.bmp').convert()
        image.set_colorkey((0,0,0))
        self.stimlibfight.addpicture(image)
        image = pygame.image.load('./pics/playergnollfighterfight2-48x48.bmp').convert()
        image.set_colorkey((0,0,0))
        self.stimlibfight.addpicture(image)
        image = pygame.image.load('./pics/playergnollfighterfight3-48x48.bmp').convert()
        image.set_colorkey((0,0,0))
        self.stimlibfight.addpicture(image)
        image = pygame.image.load('./pics/playergnollfighterfight3-48x48.bmp').convert()
        image.set_colorkey((0,0,0))
        self.stimlibfight.addpicture(image)

    def askclass(self):
        return "Fighter"

    def askrace(self):
        return "Bugbear"

    def askpicture(self):
        return './pics/taskbar-PC-gnoll.bmp'

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from stateimagelibrary import *
from playerbase import *

class PlayerHumanFighter(PlayerBase):
    "Player Fighter"
    def __init__(self,heartmeter):
        PlayerBase.__init__(self,heartmeter)


# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from stateimagelibrary import *
from playerbase import *
from rng import *
from broadsword import *
from rubysword import *

class PlayerKattaFighter(PlayerBase):
    "Player Katta Fighter"
    def __init__(self,heartmeter):
        PlayerBase.__init__(self,PlayerBase.KATTA,PlayerBase.FIGHTER,heartmeter)
        
        self.stimlib = Stateimagelibrary()	
        image = pygame.image.load('./pics/playerkattafighter1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/playerkattafighter2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/playerkattafighter3-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/playerkattafighter2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/playerkattafighter1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/playerkattafighter2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/playerkattafighter3-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)	

        self.stimlibfight = Stateimagelibrary()	
        image = pygame.image.load('./pics/playerkattafighterfight1-48x48.bmp').convert()
        image.set_colorkey((0,0,0))
        self.stimlibfight.addpicture(image)
        image = pygame.image.load('./pics/playerkattafighterfight1-48x48.bmp').convert()
        image.set_colorkey((0,0,0))
        self.stimlibfight.addpicture(image)
        image = pygame.image.load('./pics/playerkattafighterfight2-48x48.bmp').convert()
        image.set_colorkey((0,0,0))
        self.stimlibfight.addpicture(image)
        image = pygame.image.load('./pics/playerkattafighterfight2-48x48.bmp').convert()
        image.set_colorkey((0,0,0))
        self.stimlibfight.addpicture(image)
        image = pygame.image.load('./pics/playerkattafighterfight3-48x48.bmp').convert()
        image.set_colorkey((0,0,0))
        self.stimlibfight.addpicture(image)
        image = pygame.image.load('./pics/playerkattafighterfight3-48x48.bmp').convert()
        image.set_colorkey((0,0,0))
        self.stimlibfight.addpicture(image)

        self.hitpoints = 50
       	self.sword = BroadSword(0,0)
 
    def askclass(self):
        return "Fighter"

    def askrace(self):
        return "Katta"

    def askpicture(self):
        return './pics/taskbar-PC-kattafighter.bmp'

    def collidewithenemyweapon(self,room,o):
        if o.collide(room,self):
		return self ## NOTE : returns collided entity (single)
		
	return None

    def hitwithenemyweapon(self,damage):
	if damage > 0:
		print 'player is hit!'
        self.hitpoints -= damage

    def pickup(self,room):
        n = room.pickup(self)
	return n

    def fight(self,room):
        self.fightcounter = 1
        o = room.collidesword(self)
        if o:
            o.hitwithweapon(self.sword.roll())
       
    def setrubysword(self):
	self.sword = RubySword(0,0)

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from stateimagelibrary import *
#from playerbase import *

class PlayerKatta:
    "Player Fighter"
    def __init__(self,heartmeter):
        1#PlayerBase.__init__(self,heartmeter)


# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from stateimagelibrary import *
from playerbase import *
from rng import *
from broadsword import *
from rubysword import *
from inventorybow1 import *
from arrow import *
from knife import *
from bow1 import *

class PlayerLink(PlayerBase):
    "Player"
    def __init__(self,heartmeter):
        PlayerBase.__init__(self,PlayerBase.DROW,PlayerBase.MAGICUSER,heartmeter)
        
        self.stimlibright = Stateimagelibrary()	
        image = pygame.image.load('./pics/player1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/player2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/player3-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/player2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)

	self.stimlibleft = Stateimagelibrary()	
        image = pygame.image.load('./pics/playerleft1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/playerleft2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/playerleft3-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/playerleft2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)

        self.stimlibfight = Stateimagelibrary()	
        image = pygame.image.load('./pics/playerfight1-48x48.bmp').convert()
        image.set_colorkey((0,0,0))
        self.stimlibfight.addpicture(image)

        self.stimlibclimbing = Stateimagelibrary()	
        image = pygame.image.load('./pics/player-climbing-48x48.bmp').convert()
        image.set_colorkey((0,0,0))
        self.stimlibclimbing.addpicture(image)

        self.stimlibduck = Stateimagelibrary()	
        image = pygame.image.load('./pics/playerduck1-48x48.bmp').convert()
        image.set_colorkey((0,0,0))
        self.stimlibduck.addpicture(image)

        self.hitpoints = 100
        self.maxhitpoints = self.hitpoints
       	self.weapon = Knife(0,0,0,0,self)

        self.duck = 0
        self.jumpcounter = 0
 
    def askclass(self):
        return "Rogue"

    def askrace(self):
        return "Elf"

    def askpicture(self):
        return './pics/taskbar-PC.bmp'

    def collidewithenemyweapon(self,room,o):
        #FIXME2
        if o.collide(room,self):
		return self ## NOTE : returns collided entity (single)
		
	return None

    def hitwithenemyweapon(self,damage):
	if damage > 0:
		print 'player is hit!'
                self.hitpoints -= damage

    def pickup(self,room):
        n = room.pickup(self)
	return n

    def fight(self,room,game,player):
        self.fightcounter = 1

        if game.room.inventoryitem and game.room.inventoryitem.id == Inventorybow1().id:
            o = room.collidebow(self)
	    if o:
		if player.x-room.relativex < o.x: 
			room.gameobjects.append(Arrow(player.x+player.w+10-room.relativex,player.y+player.h/2+room.relativey,o.x,o.y,self))
		else:
			room.gameobjects.append(Arrow(player.x-10+room.relativex,player.y+player.h/2+room.relativey,o.x,o.y,self))
		print "fight scored hit on %s bow!" % o
		o.hitwithweapon(self.weapon.roll())
        else:
            #o = room.collidesword(self)
            o = room.collideknife(self)
            if o:
                if player.x-room.relativex < o.x:# and abs(player.y+room.relativey-o.y) <= 30:
			room.gameobjects.append(Knife(player.x+player.w+10+room.relativex,player.y+player.h/2+room.relativey,o.x,o.y,self))
		else:
			room.gameobjects.append(Knife(player.x-10+room.relativex,player.y+player.h/2+room.relativey,o.x,o.y,self))
      
                print "fight scored hit on %s knife!" % o
                o.hitwithweapon(self.weapon.roll())

    def jump(self, room):
        self.jumpcounter = 20
        ##FIXME1 self.direction = 'north'

    def update(self,room):
       if self.jumpcounter > 0 and self.jumpcounter < 140:
            room.relativey += 20
            self.jumpcounter += 15
       else:   
            self.jumpcounter = 0
            
    def setrubysword(self):
	self.weapon = RubySword(0,0)

    def setbow(self):
	self.weapon = Bow1(0,0)
	

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from stateimagelibrary import *
#from playerbase import *

class PlayerMagicUser:#(PlayerBase):
    "Player Magic User"
    def __init__(self,heartmeter):
        #PlayerBase.__init__(self,heartmeter)

        self.stimlib = Stateimagelibrary()	
        image = pygame.image.load('./pics/playerhumanmage1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/playerhumanmage2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/playerhumanmage3-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/playerhumanmage2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/playerhumanmage1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/playerhumanmage2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/playerhumanmage3-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)	

        self.stimlibfight = Stateimagelibrary()	
        image = pygame.image.load('./pics/playerhumanmagefight1-48x48.bmp').convert()
        image.set_colorkey((0,0,0))
        self.stimlibfight.addpicture(image)
        image = pygame.image.load('./pics/playerhumanmagefight1-48x48.bmp').convert()
        image.set_colorkey((0,0,0))
        self.stimlibfight.addpicture(image)
        image = pygame.image.load('./pics/playerhumanmagefight2-48x48.bmp').convert()
        image.set_colorkey((0,0,0))
        self.stimlibfight.addpicture(image)
        image = pygame.image.load('./pics/playerhumanmagefight2-48x48.bmp').convert()
        image.set_colorkey((0,0,0))
        self.stimlibfight.addpicture(image)
        image = pygame.image.load('./pics/playerhumanmagefight3-48x48.bmp').convert()
        image.set_colorkey((0,0,0))
        self.stimlibfight.addpicture(image)
        image = pygame.image.load('./pics/playerhumanmagefight3-48x48.bmp').convert()
        image.set_colorkey((0,0,0))
        self.stimlibfight.addpicture(image)


    def askclass(self):
        return "Magic User"

    def askrace(self):
        return "Human"

    def askpicture(self):
        return './pics/taskbar-PC-mage.bmp'

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from stateimagelibrary import *

class Player:
    "Player"
    def __init__(self,heartmeter):

	self.heartmeter = heartmeter

        self.x = 150 
        self.y = 150 
        self.w = 48 
        self.h = 48
	self.stimlib = Stateimagelibrary()	
        image = pygame.image.load('./pics/player1-30x30.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/player2-30x30.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/player3-30x30.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/player2-30x30.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/player1-30x30.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/player2-30x30.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/player3-30x30.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)	

        self.stimlibfight = Stateimagelibrary()	
        image = pygame.image.load('./pics/playerfight1-30x30.bmp').convert()
        image.set_colorkey((0,0,0))
        self.stimlibfight.addpicture(image)
        image = pygame.image.load('./pics/playerfight1-30x30.bmp').convert()
        image.set_colorkey((0,0,0))
        self.stimlibfight.addpicture(image)
        image = pygame.image.load('./pics/playerfight2-30x30.bmp').convert()
        image.set_colorkey((0,0,0))
        self.stimlibfight.addpicture(image)
        image = pygame.image.load('./pics/playerfight2-30x30.bmp').convert()
        image.set_colorkey((0,0,0))
        self.stimlibfight.addpicture(image)
        image = pygame.image.load('./pics/playerfight3-30x30.bmp').convert()
        image.set_colorkey((0,0,0))
        self.stimlibfight.addpicture(image)
        image = pygame.image.load('./pics/playerfight3-30x30.bmp').convert()
        image.set_colorkey((0,0,0))
        self.stimlibfight.addpicture(image)

        self.fightcounter = 0

    def drawstatic(self, screen):
        # NOTE
        if self.fightcounter > 0:
            self.fightcounter += 1
            if self.fightcounter > 10:
                self.fightcounter = 0
            self.stimlibfight.draw(screen,self.x,self.y)
            return
	self.stimlib.drawstatic(screen,self.x,self.y,0)
	
    def draw(self, screen):
        # NOTE
        if self.fightcounter > 0:
            self.fightcounter += 1
            if self.fightcounter > 10:
                self.fightcounter = 0
            self.stimlibfight.draw(screen,self.x,self.y)
            return
        self.stimlib.draw(screen, self.x,self.y)

    def fight(self,room,player):
        self.fightcounter = 1
        self.x -= 30
        self.y -= 30
        self.w += 30
        self.h += 30
        o = room.collidesword(room,player)
        if o:
            room.hitwithsword(o)
        self.x += 30
        self.y += 30
        self.w -= 30
        self.h -= 30
        
    def hit(self):
	self.heartmeter.index -= 1 
	if self.heartmeter.index <= 0:
		return 0 #FIXME1 FIX for gameover when collision with enemies 
	else:
		return 0	

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from stateimagelibrary import *
#from playerbase import *

class PlayerThief:
    "Player Fighter"
    def __init__(self,heartmeter):
        1#PlayerBase.__init__(self,heartmeter)


# Copyright (C) Johan Ceuppens 2010 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from random import *

class RNG(Gameobject):
    "Random Number God"
    def __init__(self):
        1

    def rolld6(self):
        return randint(1,6)

    def rolld4(self):
        return randint(1,4)

    def rolld2(self):
        return randint(1,2)

    def rollbroadsword(self):
        if randint(0,3) > 2:
            return 0
        
        r = self.rolld4()
        if r == 4: # critical hit
            return 4*2
        else:
            return r

    def rolllongbow(self):
        if randint(0,3) > 2:
            return 0
        
        r = self.rolld8()
        if r == 4: # critical hit
            return 8*2
        else:
            return r

    def rollbow(self):
        if randint(0,3) > 2:
            return 0
        
        r = self.rolld6()
        if r == 4: # critical hit
            return 8*2
        else:
            return r

    def rollgoblinknife(self):
        if randint(0,3) <= 2:
            return 0
        
        r = self.rolld2()
        return r

    def rollknife(self):
        if randint(0,3) <= 0:
            return 0
        
        r = self.rolld4()
        return r

    def rollbullfrog(self):
        if randint(0,3) <= 2:
            return 0
        
        r = self.rolld2()
        return r

    def rollknight(self):
        if randint(0,30) <= 28:
            return 0
        
        r = self.rolld6()
        return r

    def rollskeleton(self):
        if randint(0,3) <= 2:
            return 0
        
        r = self.rolld2()
        return r

    def rollscorpionred(self):
        if randint(0,3) <= 2:
            return 0
        
        r = self.rolld2()
        return r
   
    def rollbeholderbatzap(self):
	if randint(0,4) <= 3:
		return 0

	r = self.rolld2()
	return r
    def rollbeholderzap(self):
	if randint(0,1) == 0:
		return 0

	r = self.rolld4()
	return r

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from roadsign import *
from stateimagelibrary import *
import random
from time import *

class RoadSignInn(RoadSign):
    ""
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.image = pygame.image.load('./pics/roadsign2-36x36.bmp').convert()
        self.image.set_colorkey((0,0,0)) 
      
    def talk(self, screen,font):
        if self.talkcounter == 0:
            return
        
        if self.talkcounter > 1:
                self.talkcounter = 0
                return 
        talkover = 0
        while talkover == 0:
            pygame.display.update()
            if self.talkcounter == 1:
                screen.blit(font.render("Friendly Arm Inn", 6, (255,255,255)), (10,100))
            for event in pygame.event.get():
                if event.type == QUIT:
                    return
                elif event.type == KEYDOWN:
                    if event.key == K_z:
                        talkover = 1
                        self.talkcounter += 1
                

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from time import *

class RoadSign(Gameobject):
    ""
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 50
        self.h = 50 
        self.image = pygame.image.load('./pics/roadsign1-36x36.bmp').convert()
        self.image.set_colorkey((0,0,0)) 
        self.talkcounter = 0
        self.hitpoints = 3000 # FIXME destroy roadsign
        
    def draw(self, screen, room):
        screen.blit(self.image, (self.x+room.relativex,self.y+room.relativey))
	    
	     
    def update(self,room,player):
        1

    def collide(self, room, player):
        # FIXME NOTE : collision is different
        #print 'gameobject x=%d y=%d player x=%d y=%d' % (self.x,self.y,player.x-room.relativex,player.y-room.relativey)
	if (player.x-room.relativex >= self.x-self.w  and 
	player.x-room.relativex <= self.x+self.w+self.w and 
	player.y-room.relativey >= self.y and#-self.h and 
	player.y-room.relativey <= self.y + self.h):
	    print "collision with Roadsign!"
	    return 2
	else:
	    return 0
	
    def talk(self, screen,font):
        if self.talkcounter == 0:
            return
        
        if self.talkcounter > 1:
                self.talkcounter = 0
                return 
        talkover = 0
        while talkover == 0:
            pygame.display.update()
            if self.talkcounter == 1:
                screen.blit(font.render("<- Dragonback Mountains - Elf Village ->", 6, (255,255,255)), (100,100))
            for event in pygame.event.get():
                if event.type == QUIT:
                    return
                elif event.type == KEYDOWN:
                    if event.key == K_z or event.key == K_x:
                        talkover = 1
                        self.talkcounter += 1
                

# Copyright (C) Johan Ceuppens 2010 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *

class Rope:
    "Game object"
    def __init__(self, xx,yy,hh):
	self.x = xx
        self.y = yy 
        self.w = 27
        self.h = hh
        
        ## dungeon statue as default picture
        ## self.image = pygame.image.load('./pics/dungeon-statue1-36x36.bmp').convert()
        self.image = pygame.image.load('./pics/nopicture.bmp').convert()
        self.image.set_colorkey((0,0,0)) 
        self.hitpoints = 100000000
        # NOTE : decrease 1 hitpoint with default sword
        
    def draw(self, screen, room):
        screen.blit(self.image,(self.x+room.relativex+self.w*2,self.y+room.relativey))
	    
	     
    def collidewithrope(self, room, player):
        #print 'rope x=%d y=%d player x=%d y=%d' % (self.x,self.y,player.x-room.relativex,player.y-room.relativey)
	if (player.x-room.relativex > self.x and 
	player.x-room.relativex < self.x+self.w and 
	player.y-room.relativey > self.y and
	player.y-room.relativey < self.y + self.h):
	    #print "collision with Rope!"
	    return 1 
	else:
	    return 0
    
    def update(self,room,player):
	1

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from rng import *

class RubySword(Gameobject):
    "Ruby Sword"
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 36
        self.h = 36
	self.stimlib = Stateimagelibrary()		
        image = pygame.image.load('./pics/taskbar-rubysword1-32x32.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)	
	self.hitpoints = 10	

    def draw(self, screen, room):
        self.stimlib.draw(screen, self.x+room.relativex,self.y+room.relativey)
	
	     
    def update(self,room,player):
	1

    def pickup(self, room):
	return 5

    def collide(self, room, player):
        # FIX BUG
        ###print 'gameobject x=%d y=%d player x=%d y=%d' % (self.x,self.y,player.x-room.relativex,player.y-room.relativey)
        #print 'gameobject x=%d y=%d player x=%d y=%d' % (self.x,self.y,player.x-room.relativex,player.y-room.relativey)
	if (player.x-room.relativex > self.x  and 
	player.x-room.relativex < self.x+self.w and 
	player.y-room.relativey > self.y and 
	player.y-room.relativey < self.y + self.h):
	    print "collision with RubySword!"
	    return 5 
	else:
	    return 0 ## for game self.talker

    def collidewithsword(self, room, player):
	return 0

    def roll(self):
	return RNG().rollrubysword()        

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from rng import *
from time import *
from math import *

class ScorpionRed1(Gameobject):
    "Red Scorpion"
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 60
        self.h = 60
        self.theta = 0
        self.PI = 3.14152829
        self.hitpoints = 4
        
	self.stimlibleft = Stateimagelibrary()	
	self.stimlibright = Stateimagelibrary()	
	self.stimlibdown = Stateimagelibrary()	
	self.stimlibup = Stateimagelibrary()	
        image = pygame.image.load('./pics/scorpionredleft1-60x60.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/scorpionredleft1-60x60.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/scorpionredleft1-60x60.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/scorpionredleft1-60x60.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/scorpionredleft2-60x60.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/scorpionredleft2-60x60.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/scorpionredleft2-60x60.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/scorpionredleft2-60x60.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/scorpionredleft3-60x60.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/scorpionredleft3-60x60.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/scorpionredleft3-60x60.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/scorpionredleft3-60x60.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/scorpionredleft3-60x60.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/scorpionredleft3-60x60.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/scorpionredleft3-60x60.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/scorpionredleft3-60x60.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/scorpionredleft2-60x60.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/scorpionredleft2-60x60.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/scorpionredleft2-60x60.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/scorpionredleft2-60x60.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	
        image = pygame.image.load('./pics/scorpionredright1-60x60.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/scorpionredright1-60x60.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/scorpionredright1-60x60.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/scorpionredright1-60x60.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/scorpionredright2-60x60.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/scorpionredright2-60x60.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/scorpionredright2-60x60.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/scorpionredright2-60x60.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/scorpionredright3-60x60.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/scorpionredright3-60x60.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/scorpionredright3-60x60.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/scorpionredright3-60x60.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/scorpionredright3-60x60.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/scorpionredright2-60x60.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/scorpionredright2-60x60.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/scorpionredright2-60x60.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/scorpionredright2-60x60.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)

	self.talkcounter = 0
	self.direction = "left"

    def draw(self, screen, room):
	if (self.direction == "left"):
            self.stimlibleft.draw(screen, self.x+room.relativex,self.y+room.relativey)
	elif (self.direction == "right"):
            self.stimlibright.draw(screen, self.x+room.relativex,self.y+room.relativey)
##	elif (self.direction == "down"):
##            self.stimlibdown.draw(screen, self.x+room.relativex,self.y+room.relativey)
##	elif (self.direction == "up"):
##            self.stimlibup.draw(screen, self.x+room.relativex,self.y+room.relativey)
##	    
	     
    def update(self,room,player):
	if room.collidewithenemy(self):
	    if (self.direction == "right"):
	        self.x -=4
	        self.direction = "left" 
	    elif (self.direction == "left"):
	        self.x +=4
	        self.direction = "right"
##	    elif (self.direction == "down"):
##	        self.y -=4
##	        self.direction = "up" 
##	    elif (self.direction == "up"):
##	        self.y +=4
##	        self.direction = "down"



	if player.x+28-room.relativex < self.x:
		self.x -= 3
		self.direction = "left"
	if player.x-28-room.relativex > self.x:
		self.direction = "right"
		self.x += 3	




##	if player.y+10-room.relativey < self.y:
##		self.direction = "up"
##		self.y -= 2
##	if player.y-10-room.relativey > self.y:
##		self.direction = "down"
##		self.y += 2

        self.theta -= .1
        
        if self.theta > self.PI/2:## or self.y < player.y:
            self.theta = 0
        self.y += sin(self.theta) * 1
      
        

    def collide(self, room, player):
        # FIX BUG
        #print 'gameobject x=%d y=%d player x=%d y=%d' % (self.x,self.y,player.x-room.relativex,player.y-room.relativey)
	if (player.x-room.relativex > self.x-self.w  and 
	player.x-room.relativex < self.x+self.w+self.w and 
	player.y-room.relativey > self.y-self.h and 
	player.y-room.relativey < self.y + self.h +self.h):
	    #print "collision with Game Object!"
	    return 1 
	else:
	    return 0 ## for game self.talker


    def fight(self,room,player):
        self.fightcounter = 1
        o = player.collidewithenemyweapon(room,self)
        if o:
            player.hitwithenemyweapon(RNG().rollbullfrog())

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from rng import *
from time import *
from math import *
from scorpionred1 import *

class ScorpionRed2(ScorpionRed1):
    "Red Scorpion"
    def __init__(self,xx,yy):
	ScorpionRed1.__init__(self, xx, yy)
    
	     
    def update(self,room,player):
	self.fall(room,player)
##	if player.x-room.relativex < self.x:
##		self.x -= 3
##		self.direction = "left"
##	if player.x-room.relativex > self.x:
##		self.direction = "right"
##		self.x += 3	  

    ### FIXME BUG i != self !
    def fall(self, room,player):
        self.y += 4
        for i in room.gameobjects:
	    if i != None and i != self and self.fallcollidelocal(room, i):
#                print 'scorpionred3 x=%d y=%d o  x=%d y=%d' % (self.x,self.y,i.x,i.y+i.h)
                self.y -= 4
		return 1 # 1 FIXME
        return 0

    def fallcollidelocal(self, room, o):
        # FIX BUG
        #print 'scorpionred3 x=%d y=%d player x=%d y=%d' % (self.x,self.y,o.x,o.y+o.h)
	if (o.y+o.h > self.y and 
	o.y+o.h < self.y + self.h):
            #print 'scorpionred3 x=%d y=%d player x=%d y=%d' % (self.x,self.y,o.x,o.y+o.h)
	    #print "collision with Game Object!"
	    return 1 
	else:
	    return 0 ## for game self.talker


    def fight(self,room,player):
        self.fightcounter = 1
        o = player.collidewithenemyweapon(room,self)
        if o:
            player.hitwithenemyweapon(RNG().rollscorpionred())

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from rng import *
from time import *
from math import *
from scorpionred2 import *

class ScorpionRed3(ScorpionRed2):
    "Red Scorpion"
    def __init__(self,xx,yy):
	ScorpionRed1.__init__(self, xx, yy)
        self.direction = "right"
	     
    def update(self,room,player):
	self.fall(room,player)
        if (self.direction == "right"):
            self.x +=4                
        elif (self.direction == "left"):
            self.x -=4

##    def collideboxes(self, room, entityorbox):
##        # NOTE: that no relx rely from  map are needed
##        #print 'gameobject x=%d y=%d entityorbox x=%d y=%d' % (self.x,self.y,entityorbox.x-room.relativex,entityorbox.y-room.relativey)
####	if (entityorbox.x > self.x  and 
####	entityorbox.x < self.x+self.w and
##        
##	if (entityorbox.x + entityorbox.w >= self.x and entityorbox.x <= self.x and
##            entityorbox.y + entityorbox.h >= self.y and entityorbox.y <= self.y):# and
##    #        entityorbox.y >= self.y):
##	    return 1 
##	else:
##	    return 0 ## for game self.talker

    def fight(self,room,player):
        self.fightcounter = 1
        o = player.collidewithenemyweapon(room,self)
        if o:
            player.hitwithenemyweapon(RNG().rollscorpionred())

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from rng import *
from time import *
from math import *
from scorpionred3 import *

class ScorpionRed4(ScorpionRed3):
    "Red Scorpion 4"
    def __init__(self,xx,yy):
	ScorpionRed1.__init__(self, xx, yy)
        self.direction = "right"
	     
    def update(self,room,player):
	self.fall(room,player)

        # activation pixel
        #print 'x=%d y=%d playerx=%d playery=%d' % (self.x,self.y,player.x-room.relativex,player.y-room.relativey)
        if player.x-room.relativex < 2600 and player.y-room.relativey > 300:
            return
	
        if (self.direction == "right"):
            self.x +=4                
        elif (self.direction == "left"):
            self.x -=4



# Copyright (C) Johan Ceuppens 2010 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *

class Selector:
    "Class and Race Selector"
    def __init__(self, screen, font):
        self.screen = screen
        self.font = font
        self.background = pygame.image.load('./pics/blank.bmp').convert()
        self.klass = "Fighter"
        self.race = "Human"
        # fighters
        self.humanfighterimage = pygame.image.load('./pics/taskbar-PC.bmp').convert()
        self.gnollfighterimage = pygame.image.load('./pics/taskbar-PC-gnoll.bmp').convert()
        self.kattafighterimage = pygame.image.load('./pics/taskbar-PC-kattafighter.bmp').convert()
        self.elffighterimage = pygame.image.load('./pics/taskbar-PC-elffighter.bmp').convert()
        self.abeillefighterimage = pygame.image.load('./pics/taskbar-PC-abeillefighter.bmp').convert()
        # magic users
       
        # thieves
         
    def draw(self):
        # fighters
        self.screen.blit(self.background, (0, 300))       
        self.screen.blit(self.humanfighterimage, (0,0))
        self.screen.blit(self.gnollfighterimage, (50,0))
        self.screen.blit(self.kattafighterimage, (100,0))
        self.screen.blit(self.elffighterimage, (150,0))
        self.screen.blit(self.abeillefighterimage, (200,0))
        # magic users
        

    def select(self):
        while 1:
                self.draw()
                pygame.display.update()
                for event in pygame.event.get():
                    if event.type == QUIT:
                        return
                    if event.type == pygame.MOUSEBUTTONDOWN:
                        position = pygame.mouse.get_pos()
                        mousex = position[0]
                        mousey = position[1]
                        
                        if mousex > 0 and mousex < 50 and mousey > 0 and mousey < 50:
                            self.race = "Human"    
                            self.klass = "Fighter"
                            return
                        elif mousex > 50 and mousex < 100 and mousey > 0 and mousey < 50:
                            self.race = "Bugbear"    
                            self.klass = "Fighter"
                            return
                        elif mousex > 100 and mousex < 150 and mousey > 0 and mousey < 50:
                            self.race = "Katta"    
                            self.klass = "Fighter"
                            return
                        elif mousex > 150 and mousex < 200 and mousey > 0 and mousey < 50:
                            self.race = "Elven"    
                            self.klass = "Fighter"
                            return
                        elif mousex > 200 and mousex < 250 and mousey > 0 and mousey < 50:
                            self.race = "Abeille"    
                            self.klass = "Fighter"
                            return

    def askrace(self):
        return self.race

    def askclass(self):
        return self.klass

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from rng import *
from time import *
from math import *

class Skeleton1(Gameobject):
    "Skeleton"
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 64
        self.h = 64
        self.theta = 0
        self.PI = 3.14152829
        self.hitpoints = 4
        
	self.stimlibleft = Stateimagelibrary()	
	self.stimlibright = Stateimagelibrary()	
	self.stimlibdown = Stateimagelibrary()	
	self.stimlibup = Stateimagelibrary()	
        image = pygame.image.load('./pics/skeleton1-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/skeleton1-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/skeleton1-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/skeleton1-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/skeleton2-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/skeleton2-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/skeleton2-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/skeleton2-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/skeleton3-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/skeleton3-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/skeleton3-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/skeleton3-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	
	image = pygame.image.load('./pics/skeleton3-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/skeleton3-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/skeleton3-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/skeleton3-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/skeleton2-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/skeleton2-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/skeleton2-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/skeleton2-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	
        image = pygame.image.load('./pics/skeletonright1-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/skeletonright1-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/skeletonright1-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/skeletonright1-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/skeletonright2-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/skeletonright2-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/skeletonright2-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/skeletonright2-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/skeletonright3-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/skeletonright3-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/skeletonright3-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/skeletonright3-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/skeletonright3-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/skeletonright2-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/skeletonright2-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/skeletonright2-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/skeletonright2-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)

	self.talkcounter = 0
	self.direction = "left"

    def draw(self, screen, room):
	if (self.direction == "left"):
            self.stimlibleft.draw(screen, self.x+room.relativex,self.y+room.relativey)
	elif (self.direction == "right"):
            self.stimlibright.draw(screen, self.x+room.relativex,self.y+room.relativey)
##	elif (self.direction == "down"):
##            self.stimlibdown.draw(screen, self.x+room.relativex,self.y+room.relativey)
##	elif (self.direction == "up"):
##            self.stimlibup.draw(screen, self.x+room.relativex,self.y+room.relativey)
##	    
	     
    def update(self,room,player):

        self.fall(room,player)
        
	if room.collidewithenemy(self):
	    if (self.direction == "right"):
	        self.x -=4
	        self.direction = "left" 
	    elif (self.direction == "left"):
	        self.x +=4
	        self.direction = "right"
##	    elif (self.direction == "down"):
##	        self.y -=4
##	        self.direction = "up" 
##	    elif (self.direction == "up"):
##	        self.y +=4
##	        self.direction = "down"

	if player.x+28-room.relativex < self.x:
		self.x -= 3
		self.direction = "left"
	if player.x-28-room.relativex > self.x:
		self.direction = "right"
		self.x += 3	
##	if player.y+10-room.relativey < self.y:
##		self.direction = "up"
##		self.y -= 2
##	if player.y-10-room.relativey > self.y:
##		self.direction = "down"
##		self.y += 2

        self.theta -= .1
        
        if self.theta > self.PI/2:## or self.y < player.y:
            self.theta = 0
        self.y += sin(self.theta) * 1
      
        

    def collide(self, room, player):
        # FIX BUG
        #print 'gameobject x=%d y=%d player x=%d y=%d' % (self.x,self.y,player.x-room.relativex,player.y-room.relativey)
	if (player.x-room.relativex > self.x  and 
	player.x-room.relativex < self.x+self.w and 
	player.y-room.relativey > self.y and 
	player.y-room.relativey < self.y + self.h):
	    #print "collision with Skeleton!"
	    return 1 
	else:
	    return 0 ## for game self.talker

    def fall(self, room,player):
        for i in room.gameobjects:
	    if i != None and i != self and i.collideboxes(room, self):
#                print 'spider1 x=%d y=%d o  x=%d y=%d' % (self.x,self.y,i.x,i.y+i.h)
                
		return 1 # 1 FIXME
	self.y += 10
        return 0
    
    def fight(self,room,player):
        self.fightcounter = 1
        o = player.collidewithenemyweapon(room,self)
        if o:
            player.hitwithenemyweapon(RNG().rollskeleton())

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from rng import *
from time import *
from math import *

class Skeleton2(Gameobject):
    "Skeleton with activation pixels"
    def __init__(self,xx,yy, activationbox):
	Gameobject.__init__(self, xx, yy)
        self.w = 64
        self.h = 64
        self.theta = 0
        self.PI = 3.14152829
        self.hitpoints = 4

        self.activationbox = activationbox
        
	self.stimlibleft = Stateimagelibrary()	
	self.stimlibright = Stateimagelibrary()	
	self.stimlibdown = Stateimagelibrary()	
	self.stimlibup = Stateimagelibrary()	
        image = pygame.image.load('./pics/skeleton1-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/skeleton1-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/skeleton1-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/skeleton1-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/skeleton2-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/skeleton2-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/skeleton2-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/skeleton2-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/skeleton3-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/skeleton3-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/skeleton3-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/skeleton3-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	
	image = pygame.image.load('./pics/skeleton3-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/skeleton3-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/skeleton3-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/skeleton3-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/skeleton2-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/skeleton2-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/skeleton2-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/skeleton2-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	
        image = pygame.image.load('./pics/skeletonright1-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/skeletonright1-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/skeletonright1-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/skeletonright1-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/skeletonright2-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/skeletonright2-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/skeletonright2-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/skeletonright2-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/skeletonright3-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/skeletonright3-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/skeletonright3-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/skeletonright3-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/skeletonright3-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/skeletonright2-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/skeletonright2-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/skeletonright2-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/skeletonright2-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)

	self.talkcounter = 0
	self.direction = "left"

	self.activated = None

    def draw(self, screen, room):
	if (self.direction == "left"):
            self.stimlibleft.draw(screen, self.x+room.relativex,self.y+room.relativey)
	elif (self.direction == "right"):
            self.stimlibright.draw(screen, self.x+room.relativex,self.y+room.relativey)
##	elif (self.direction == "down"):
##            self.stimlibdown.draw(screen, self.x+room.relativex,self.y+room.relativey)
##	elif (self.direction == "up"):
##            self.stimlibup.draw(screen, self.x+room.relativex,self.y+room.relativey)
##	    
	     
    def update(self,room,player):


        if not self.activated and self.activationbox and self.activationbox.collideXY(room,player):
            self.activated = 1
            return
            
        self.fall(room,player)
        
	if room.collidewithenemy(self):
	    if (self.direction == "right"):
	        self.x -=4
	        self.direction = "left" 
	    elif (self.direction == "left"):
	        self.x +=4
	        self.direction = "right"
##	    elif (self.direction == "down"):
##	        self.y -=4
##	        self.direction = "up" 
##	    elif (self.direction == "up"):
##	        self.y +=4
##	        self.direction = "down"

	if player.x+28-room.relativex < self.x:
		self.x -= 3
		self.direction = "left"
	if player.x-28-room.relativex > self.x:
		self.direction = "right"
		self.x += 3	
##	if player.y+10-room.relativey < self.y:
##		self.direction = "up"
##		self.y -= 2
##	if player.y-10-room.relativey > self.y:
##		self.direction = "down"
##		self.y += 2

        self.theta -= .1
        
        if self.theta > self.PI/2:## or self.y < player.y:
            self.theta = 0
        self.y += sin(self.theta) * 1
      
        

    def collide(self, room, player):
        # FIX BUG
        #print 'gameobject x=%d y=%d player x=%d y=%d' % (self.x,self.y,player.x-room.relativex,player.y-room.relativey)
	if (player.x-room.relativex > self.x  and 
	player.x-room.relativex < self.x+self.w and 
	player.y-room.relativey > self.y and 
	player.y-room.relativey < self.y + self.h):
	    #print "collision with Skeleton!"
	    return 1 
	else:
	    return 0 ## for game self.talker

    def fall(self, room,player):
        for i in room.gameobjects:
	    if i != None and i != self and i.collideboxes(room, self):
#                print 'spider1 x=%d y=%d o  x=%d y=%d' % (self.x,self.y,i.x,i.y+i.h)
                
		return 1 # 1 FIXME
	self.y += 10
        return 0
    
    def fight(self,room,player):
        self.fightcounter = 1
        o = player.collidewithenemyweapon(room,self)
        if o:
            player.hitwithenemyweapon(RNG().rollskeleton())

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from rng import *
from time import *
from math import *

class Skeleton3(Gameobject):
    "Skeleton with activation pixels"
    def __init__(self,xx,yy, activationbox):
	Gameobject.__init__(self, xx, yy)
        self.w = 64
        self.h = 64
        self.theta = 0
        self.PI = 3.14152829
        self.hitpoints = 4

        self.activationbox = activationbox
        
	self.stimlibleft = Stateimagelibrary()	
	self.stimlibright = Stateimagelibrary()	
	self.stimlibdown = Stateimagelibrary()	
	self.stimlibup = Stateimagelibrary()	
        image = pygame.image.load('./pics/skeleton1-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/skeleton1-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/skeleton1-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/skeleton1-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/skeleton2-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/skeleton2-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/skeleton2-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/skeleton2-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/skeleton3-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/skeleton3-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/skeleton3-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/skeleton3-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	
	image = pygame.image.load('./pics/skeleton3-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/skeleton3-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/skeleton3-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/skeleton3-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/skeleton2-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/skeleton2-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/skeleton2-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/skeleton2-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
	
        image = pygame.image.load('./pics/skeletonright1-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/skeletonright1-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/skeletonright1-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/skeletonright1-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/skeletonright2-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/skeletonright2-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/skeletonright2-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/skeletonright2-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/skeletonright3-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/skeletonright3-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/skeletonright3-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/skeletonright3-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/skeletonright3-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/skeletonright2-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/skeletonright2-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/skeletonright2-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/skeletonright2-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)

	self.talkcounter = 0
	self.direction = "left"

	self.activated = None

    def draw(self, screen, room):
	if (self.direction == "left"):
            self.stimlibleft.draw(screen, self.x+room.relativex,self.y+room.relativey)
	elif (self.direction == "right"):
            self.stimlibright.draw(screen, self.x+room.relativex,self.y+room.relativey)
##	elif (self.direction == "down"):
##            self.stimlibdown.draw(screen, self.x+room.relativex,self.y+room.relativey)
##	elif (self.direction == "up"):
##            self.stimlibup.draw(screen, self.x+room.relativex,self.y+room.relativey)
##	    
	     
    def update(self,room,player):


        if not self.activated and self.activationbox and self.activationbox.collideXY(room,player):
            self.activated = 1
            return


        if not self.collideobjectXY(room,player):
            self.fall(room,player)
        
	if room.collidewithenemy(self):
	    if (self.direction == "right"):
	        self.x -=4
	        self.direction = "left" 
	    elif (self.direction == "left"):
	        self.x +=4
	        self.direction = "right"
##	    elif (self.direction == "down"):
##	        self.y -=4
##	        self.direction = "up" 
##	    elif (self.direction == "up"):
##	        self.y +=4
##	        self.direction = "down"

	if player.x+28-room.relativex < self.x:
		self.x -= 3
		self.direction = "left"
	if player.x-28-room.relativex > self.x:
		self.direction = "right"
		self.x += 3	
##	if player.y+10-room.relativey < self.y:
##		self.direction = "up"
##		self.y -= 2
##	if player.y-10-room.relativey > self.y:
##		self.direction = "down"
##		self.y += 2

        self.theta -= .1
        
        if self.theta > self.PI/2:## or self.y < player.y:
            self.theta = 0
        self.y += sin(self.theta) * 1
      
        

    def collide(self, room, player):
        # FIX BUG
        #print 'gameobject x=%d y=%d player x=%d y=%d' % (self.x,self.y,player.x-room.relativex,player.y-room.relativey)
	if (player.x-room.relativex > self.x  and 
	player.x-room.relativex < self.x+self.w and 
	player.y-room.relativey > self.y and 
	player.y-room.relativey < self.y + self.h):
	    #print "collision with Skeleton!"
	    return 1 
	else:
	    return 0 ## for game self.talker

    def fall(self, room,player):
        for i in room.gameobjects:
	    if i != None and i != self and i.collideboxes(room, self):
#                print 'spider1 x=%d y=%d o  x=%d y=%d' % (self.x,self.y,i.x,i.y+i.h)
                
		return 1 # 1 FIXME
	self.y += 10
        return 0
    
    def fight(self,room,player):
        self.fightcounter = 1
        o = player.collidewithenemyweapon(room,self)
        if o:
            player.hitwithenemyweapon(RNG().rollskeleton())

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from rng import *
from time import *
from math import *

class Spider1(Gameobject):
    "Spider 1"
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 48
        self.h = 48
        self.theta = 0
        self.PI = 3.14152829
        self.hitpoints = 4
        
	self.stimlibleft = Stateimagelibrary()	
	self.stimlibright = Stateimagelibrary()	
	self.stimlibdown = Stateimagelibrary()	
	self.stimlibup = Stateimagelibrary()	
        image = pygame.image.load('./pics/spiderleft1-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/spiderleft1-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/spiderleft1-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/spiderleft1-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/spiderleft2-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/spiderleft2-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/spiderleft2-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/spiderleft2-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/spiderleft3-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/spiderleft3-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/spiderleft3-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/spiderleft3-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/spiderleft3-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/spiderleft3-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/spiderleft3-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/spiderleft3-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/spiderleft2-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/spiderleft2-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/spiderleft2-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/spiderleft2-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	
        image = pygame.image.load('./pics/spiderright1-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/spiderright1-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/spiderright1-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/spiderright1-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/spiderright2-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/spiderright2-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/spiderright2-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/spiderright2-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/spiderright3-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/spiderright3-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/spiderright3-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/spiderright3-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/spiderright3-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/spiderright2-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/spiderright2-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/spiderright2-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/spiderright2-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)

	self.talkcounter = 0
	self.direction = "right"

    def draw(self, screen, room):
	if (self.direction == "left"):
            self.stimlibleft.draw(screen, self.x+room.relativex,self.y+room.relativey)
	elif (self.direction == "right"):
            self.stimlibright.draw(screen, self.x+room.relativex,self.y+room.relativey)
##	elif (self.direction == "down"):
##            self.stimlibdown.draw(screen, self.x+room.relativex,self.y+room.relativey)
##	elif (self.direction == "up"):
##            self.stimlibup.draw(screen, self.x+room.relativex,self.y+room.relativey)
##	    
	     
    def update(self,room,player):
        # splut!
        self.fall(room,player)
            
                
##	if not room.collideboxeswithenemy(self):
##            self.y += 10
            #return
##	    if (self.direction == "right"):
##	        self.x -=4
##	        self.direction = "left" 
##	    elif (self.direction == "left"):
##	        self.x +=4
##	        self.direction = "right"
##	    elif (self.direction == "down"):
##	        self.y -=4
##	        self.direction = "up" 
##	    elif (self.direction == "up"):
##	        self.y +=4
##	        self.direction = "down"



	if player.x-room.relativex < self.x:
		self.x -= 3
		self.direction = "left"
	if player.x-room.relativex > self.x:
		self.direction = "right"
		self.x += 3	




##	if player.y+10-room.relativey < self.y:
##		self.direction = "up"
##		self.y -= 2
##	if player.y-10-room.relativey > self.y:
##		self.direction = "down"
##		self.y += 2

        self.theta -= .1
        
        if self.theta > self.PI/2:## or self.y < player.y:
            self.theta = 0
        self.y += sin(self.theta) * 1
      
        

    def collide(self, room, player):
        # FIX BUG
        #print 'gameobject x=%d y=%d player x=%d y=%d' % (self.x,self.y,player.x-room.relativex,player.y-room.relativey)
	if (player.x-room.relativex > self.x-self.w  and 
	player.x-room.relativex < self.x+self.w+self.w and 
	player.y-room.relativey > self.y-self.h and 
	player.y-room.relativey < self.y + self.h +self.h):
	    #print "collision with Game Object!"
	    return 1 
	else:
	    return 0 ## for game self.talker

    def fall(self, room,player):
        for i in room.gameobjects:
	    if i != None and i != self and i.collideboxes(room, self):
#                print 'spider1 x=%d y=%d o  x=%d y=%d' % (self.x,self.y,i.x,i.y+i.h)
                
		return 1 # 1 FIXME
	self.y += 10
        return 0

##    def fallcollidelocal(self, room, o):
##        # FIX BUG
##        #print 'spider1 x=%d y=%d player x=%d y=%d' % (self.x,self.y,o.x,o.y+o.h)
##	if (o.y+o.h < self.y):# and 
##	#o.y+o.h < self.y + self.h):
##            #print 'spider1 x=%d y=%d player x=%d y=%d' % (self.x,self.y,o.x,o.y+o.h)
##	    #print "collision with Game Object!"
##	    return 1 
##	else:
##	    return 0 ## for game self.talker



    def fight(self,room,player):
        self.fightcounter = 1
        o = player.collidewithenemyweapon(room,self)
        if o:
            player.hitwithenemyweapon(RNG().rollbullfrog())

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from spider1 import *
from stateimagelibrary import *
import random
from rng import *
from time import *
from math import *

class Spider2(Spider1):
    "Cave Spider"
    def __init__(self,xx,yy):
	Spider1.__init__(self, xx, yy)
	self.direction = "right"

#!/usr/local/bin/python
# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

class Stateimagelibrary:
    def __init__(self):
	self.index = 0
	self.max = 0
	self.list = []
    def addpicture(self, image):
	self.list.append(image)
	self.max += 1

    def drawstatic(self, screen, xx, yy, index):
	if (self.index >= self.max):
            self.index = 0

	screen.blit(self.list[index],(xx,yy)) 

    def draw(self, screen, xx, yy):
	if (self.index >= self.max):
            self.index = 0

	screen.blit(self.list[self.index],(xx,yy)) 
	self.index += 1	

# Copyright (C) Johan Ceuppens 2010 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *

class Taskbar:
    "Taskbar"
    def __init__(self, screen, font, player):
        self.screen = screen	
        self.font = font
        self.player = player
        #self.foreground = pygame.image.load('./pics/taskbar01.bmp').convert()
        #self.foreground.set_colorkey((0,0,0)) 
        self.pc = pygame.image.load(player.askpicture()).convert()
        self.swordimage = pygame.image.load('./pics/sword1-36x36.bmp').convert()
        self.swordimage.set_colorkey((0,0,255))

        self.font2 = pygame.font.SysFont("Vera", 25)
        
###        self.lifeimage = pygame.image.load('./pics/life1.bmp').convert()

##    def drawlife(self):
##	for i in range(0,self.player.hitpoints):
##		self.screen.blit(self.lifeimage, (10+i*2,10))

    def setswordimage(self, imagefilename,r,g,b):
        self.swordimage = pygame.image.load(imagefilename).convert()
        self.swordimage.set_colorkey((r,g,b)) 

    def draw(self,game):
        1#self.screen.blit(self.foreground, (0,0))
##        
        self.screen.blit(self.pc, (10, 10))
        #self.screen.blit(self.font.render(self.player.askrace() + ' ' + self.player.askclass(), 6, (255,0,0)), (0+10,0+60))
        self.screen.blit(self.font.render(self.player.askclass(), 6, (255,0,0)), (0+10,0+60))
###       	self.drawlife()
        self.screen.blit(self.font2.render(game.room.locationtext, 6, (255,255,255)), (0+100,0+60))

        
 
        self.screen.blit(self.swordimage, (65, 10))

    def setrubysword(self):
        self.setswordimage('./pics/taskbar-rubysword1-32x32.bmp',0,0,255)

    def setsword1(self):
        self.setswordimage('./pics/sword1-36x36.bmp',0,0,255)

    def setbow(self):
        self.setswordimage('./pics/bow1-36x36.bmp',0,0,0)
        self.swordimage.set_colorkey((0,0,255)) 

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from koboldwizard import *
from time import *
from maproom import *
from box import *

class Tilebox:
    "box full o tiles"
    
# example:    self.northwall1 = Tilebox(1,1,60,48,16,1,'./pics/walldungeon1-60x48.bmp')
#               draws 16 times the picture from left to right 1 high
    def __init__(self,x,y,w,h,nx,ny,imagefilename):
        # NOTE : self.w self.h is number of w and h tiles
        self.x = x
        self.y = y
        self.w = w
        self.h = h
        self.nx = nx
        self.ny = ny
        self.image = pygame.image.load(imagefilename).convert()
	self.image.set_colorkey((0,0,255))
        
    def draw(self,screen,relx,rely):
        for j in range(0, self.ny):
            for i in range(0,self.nx):
                screen.blit(self.image,(self.x+self.w*i+relx,self.y+self.h*j+rely))

    # NOTE - player.h for fencepost errors
    def collide(self, room, player):
	if (player.x > self.x-room.relativex  and 
	 player.x < self.x-room.relativex + self.w*self.nx and 
	 player.y - player.h > self.y-room.relativey and 
	 player.y - player.h < self.y-room.relativey + self.h*self.ny):
	    print "collision in Tilebox!"	
	    return 1 
	else:
	    return 0


    def collidewithenemy(self, room, enemy):
	if (enemy.x > self.x  and 
	enemy.x < self.x+self.w*self.nx and 
	enemy.y - enemy.h > self.y and 
	enemy.y - enemy.h < self.y + self.h*self.ny):
	    #print "collision in Tilebox with enemy!"	
	    return 1 
	else:
	    return 0


# Copyright (C) Johan Ceuppens 2010 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *

class Toadstool(Gameobject):
    "Box"
    def __init__(self, xx,yy):
        Gameobject.__init__(self,xx,yy)
        self.w = 48
        self.h = 48 
        self.image = pygame.image.load('./pics/toadstool1-48x48.bmp').convert()
        self.image.set_colorkey((0,0,0)) 

    def setimage(self, imagefilename,r,g,b):
        self.image = pygame.image.load(imagefilename).convert()
        self.image.set_colorkey((r,g,b)) 

    def collide(self, room, player):
	if (player.x > self.x+room.relativex  and 
	player.x < self.x+room.relativex+self.w and 
	player.y > self.y+room.relativey and 
	player.y < self.y+room.relativey + self.h):
	    print "collision in toadstool!"	
	    return 2 
	else:
	    return 0

# Copyright (C) Johan Ceuppens 2010 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *

class Tree2(Gameobject):
    "Tree 2"
    def __init__(self, xx,yy):
        Gameobject.__init__(self,xx,yy)
        self.w = 92 
        self.h = 92 
        self.image = pygame.image.load('./pics/tree2-150x150.bmp').convert()
        self.image.set_colorkey((0,0,0)) 

# Copyright (C) Johan Ceuppens 2010 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *

class Tree(Gameobject):
    "Tree"
    def __init__(self, xx,yy):
        Gameobject.__init__(self,xx,yy)
        self.w = 92 
        self.h = 92 
        self.image = pygame.image.load('./pics/tree1-92x92.bmp').convert()
        self.image.set_colorkey((0,0,0)) 

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random

class TurtleFlying(Gameobject):
    "TurtleFlying"
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 36
        self.h = 36 
	self.stimlibleft = Stateimagelibrary()	
	self.stimlibright = Stateimagelibrary()	
        image = pygame.image.load('./pics/turtleleft1-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/turtleleft1-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/turtleleft1-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/turtleleft1-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/turtleleft2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/turtleleft2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/turtleleft2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/turtleleft2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/turtleleft3-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/turtleleft3-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/turtleleft3-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/turtleleft3-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/turtleleft2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/turtleleft2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/turtleleft2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/turtleleft2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	

        image = pygame.image.load('./pics/turtle1-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/turtle1-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/turtle1-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/turtle1-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/turtle2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/turtle2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/turtle2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/turtle2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/turtle3-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/turtle3-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/turtle3-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/turtle3-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/turtle2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/turtle2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/turtle2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/turtle2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	

	self.direction = "left"

    def draw(self, screen, room):
	if (self.direction == "left"):
            self.stimlibleft.draw(screen, self.x+room.relativex,self.y+room.relativey)
	elif (self.direction == "right"):
            self.stimlibright.draw(screen, self.x+room.relativex,self.y+room.relativey)
	    
	     
    def update(self,room):
	if (not self.collideobjectX(room)): 
	    if (self.direction == "left"):
	        self.x +=2
	        self.direction = "right" 
	    elif (self.direction == "right"):
	        self.x -=2
	        self.direction = "left"


	if (self.direction == "left"):
	        self.x -=1 
	elif (self.direction == "right"):
	        self.x +=1

    def collide(self, room, player):
	if (player.x > self.x+room.relativex  and 
	player.x < self.x+room.relativex+self.w and 
	player.y > self.y+room.relativey and 
	player.y < self.y+room.relativey + self.h):
	    print "collision with Dark Knight!"
	    if player.hit():
		return 1 
	    else:
	    	return 2 
	else:
	    return 0

		 

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from time import *

class Venomspit(Gameobject):
    "Venom spit"
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 24
        self.h = 24 
	self.stimlib = Stateimagelibrary()
        image = pygame.image.load('./pics/venomspit-24x24.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)		

	self.direction = "down"

    def draw(self, screen, room):
        self.stimlib.draw(screen, self.x+room.relativex,self.y+room.relativey)
		    
	     
    def update(self,room):
        sleep(.01) # FIX venom spit sleep
        if (self.direction == "down"):
	        self.y +=5
	if self.y > self.SCREENH:
            room.removeobject(self)

    def collide(self, room, player):
	if (player.x > self.x+room.relativex  and 
	player.x < self.x+room.relativex+self.w and 
	player.y > self.y+room.relativey and 
	player.y < self.y+room.relativey + self.h):
	    print "collision with Venom spit!"
	    if player.hit():
		return 1 
	    else:
	    	return 2 
	else:
	    return 0

		 

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from time import *

class VenomspitUp(Gameobject):
    "Venom spit"
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 24
        self.h = 24 
	self.stimlib = Stateimagelibrary()
        image = pygame.image.load('./pics/venomspitup-24x24.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)		

	self.direction = "up"

    def draw(self, screen, room):
        self.stimlib.draw(screen, self.x+room.relativex,self.y+room.relativey)
		    
	     
    def update(self,room):
        sleep(.01) # FIX venom spit sleep
        if (self.direction == "up"):
	        self.y -=5
	if self.y > self.SCREENH:
            room.removeobject(self)

    def collide(self, room, player):
	if (player.x > self.x+room.relativex  and 
	player.x < self.x+room.relativex+self.w and 
	player.y > self.y+room.relativey and 
	player.y < self.y+room.relativey + self.h):
	    print "collision with Venom spit!"
	    if player.hit():
		return 1 
	    else:
	    	return 2 
	else:
	    return 0

		 

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from time import *

class YuanInnKeeper(Gameobject):
    ""
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 48
        self.h = 48 
        self.image = pygame.image.load('./pics/yuaninnkeeper1-48x48.bmp').convert()
        self.image.set_colorkey((0,0,255)) 
        self.talkcounter = 0
        
    def draw(self, screen, room):
        screen.blit(self.image, (self.x+room.relativex,self.y+room.relativey))
	    
	     
    def update(self,room):
        1

    def collide(self, room, player):
	if (player.x > self.x+room.relativex  and 
	player.x < self.x+room.relativex+self.w and 
	player.y > self.y+room.relativey and 
	player.y < self.y+room.relativey + self.h):
	    print "collision with Yuan Inn Keeper!"
	    return 2 
	else:
	    return 0
		 
    def talk(self, screen,font):
        if self.talkcounter == 0:
            return
        
        if self.talkcounter > 2:
                self.talkcounter = 0
                return 
        talkover = 0
        while talkover == 0:
            pygame.display.update()
            if self.talkcounter == 1:
                screen.blit(font.render("Welcome stranger.", 6, (255,255,255)), (10,100))
            elif self.talkcounter == 2:
                screen.blit(font.render("I am Yuan, Fighter-Cleric at your servive.", 6, (255,255,255)), (10,100))
            for event in pygame.event.get():
                if event.type == QUIT:
                    return
                elif event.type == KEYDOWN:
                    if event.key == K_z:
                        talkover = 1
                        self.talkcounter += 1
\end{verbatim}
\end{mylisting}


\section{\large Conclusion}


\bibliographystyle{plain}
\bibliography{refs} % refs.bib

\end{document}

                
